1313from typing import cast
1414from typing import Generic
1515from typing import Optional
16- from typing import overload
1716from typing import Pattern
1817from typing import Tuple
1918from typing import TypeVar
2221from more_itertools .more import always_iterable
2322
2423import _pytest ._code
24+ from _pytest .compat import overload
2525from _pytest .compat import STRING_TYPES
2626from _pytest .outcomes import fail
2727
2828if False : # TYPE_CHECKING
2929 from typing import Type # noqa: F401 (used in type string)
3030
31+
3132BASE_TYPE = (type , STRING_TYPES )
3233
3334
@@ -547,12 +548,12 @@ def _is_numpy_array(obj):
547548def raises (
548549 expected_exception : Union ["Type[_E]" , Tuple ["Type[_E]" , ...]],
549550 * ,
550- match : Optional [Union [str , Pattern ]] = ...
551+ match : " Optional[Union[str, Pattern]]" = ...
551552) -> "RaisesContext[_E]" :
552553 ... # pragma: no cover
553554
554555
555- @overload
556+ @overload # noqa: F811
556557def raises (
557558 expected_exception : Union ["Type[_E]" , Tuple ["Type[_E]" , ...]],
558559 func : Callable ,
@@ -563,10 +564,10 @@ def raises(
563564 ... # pragma: no cover
564565
565566
566- def raises (
567+ def raises ( # noqa: F811
567568 expected_exception : Union ["Type[_E]" , Tuple ["Type[_E]" , ...]],
568569 * args : Any ,
569- match : Optional [Union [str , Pattern ]] = None ,
570+ match : Optional [Union [str , " Pattern" ]] = None ,
570571 ** kwargs : Any
571572) -> Union ["RaisesContext[_E]" , Optional [_pytest ._code .ExceptionInfo [_E ]]]:
572573 r"""
@@ -724,7 +725,7 @@ def __init__(
724725 self ,
725726 expected_exception : Union ["Type[_E]" , Tuple ["Type[_E]" , ...]],
726727 message : str ,
727- match_expr : Optional [Union [str , Pattern ]] = None ,
728+ match_expr : Optional [Union [str , " Pattern" ]] = None ,
728729 ) -> None :
729730 self .expected_exception = expected_exception
730731 self .message = message
0 commit comments