From e622cb7c4122abcf38a6482b1ef54b5c6cdb936a Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Fri, 2 Oct 2020 13:05:29 -0700 Subject: [PATCH] py36+: remove workaround for Union[Pattern/Match] bug --- src/_pytest/_code/code.py | 2 +- src/_pytest/python_api.py | 4 ++-- src/_pytest/recwarn.py | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/_pytest/_code/code.py b/src/_pytest/_code/code.py index 6b908bb51..595686c69 100644 --- a/src/_pytest/_code/code.py +++ b/src/_pytest/_code/code.py @@ -625,7 +625,7 @@ class ExceptionInfo(Generic[_E]): ) return fmt.repr_excinfo(self) - def match(self, regexp: "Union[str, Pattern[str]]") -> "Literal[True]": + def match(self, regexp: Union[str, Pattern[str]]) -> "Literal[True]": """Check whether the regular expression `regexp` matches the string representation of the exception using :func:`python:re.search`. diff --git a/src/_pytest/python_api.py b/src/_pytest/python_api.py index 681f83028..0a97ad393 100644 --- a/src/_pytest/python_api.py +++ b/src/_pytest/python_api.py @@ -562,7 +562,7 @@ _E = TypeVar("_E", bound=BaseException) def raises( expected_exception: Union["Type[_E]", Tuple["Type[_E]", ...]], *, - match: "Optional[Union[str, Pattern[str]]]" = ... + match: Optional[Union[str, Pattern[str]]] = ... ) -> "RaisesContext[_E]": ... @@ -740,7 +740,7 @@ class RaisesContext(Generic[_E]): self, expected_exception: Union["Type[_E]", Tuple["Type[_E]", ...]], message: str, - match_expr: Optional[Union[str, "Pattern[str]"]] = None, + match_expr: Optional[Union[str, Pattern[str]]] = None, ) -> None: self.expected_exception = expected_exception self.message = message diff --git a/src/_pytest/recwarn.py b/src/_pytest/recwarn.py index 39d6de914..17d169a77 100644 --- a/src/_pytest/recwarn.py +++ b/src/_pytest/recwarn.py @@ -41,7 +41,7 @@ def recwarn() -> Generator["WarningsRecorder", None, None]: @overload def deprecated_call( - *, match: Optional[Union[str, "Pattern[str]"]] = ... + *, match: Optional[Union[str, Pattern[str]]] = ... ) -> "WarningsRecorder": ... @@ -88,7 +88,7 @@ def deprecated_call( # noqa: F811 def warns( expected_warning: Optional[Union["Type[Warning]", Tuple["Type[Warning]", ...]]], *, - match: "Optional[Union[str, Pattern[str]]]" = ... + match: Optional[Union[str, Pattern[str]]] = ... ) -> "WarningsChecker": ... @@ -106,7 +106,7 @@ def warns( # noqa: F811 def warns( # noqa: F811 expected_warning: Optional[Union["Type[Warning]", Tuple["Type[Warning]", ...]]], *args: Any, - match: Optional[Union[str, "Pattern[str]"]] = None, + match: Optional[Union[str, Pattern[str]]] = None, **kwargs: Any ) -> Union["WarningsChecker", Any]: r"""Assert that code raises a particular class of warning. @@ -236,7 +236,7 @@ class WarningsChecker(WarningsRecorder): expected_warning: Optional[ Union["Type[Warning]", Tuple["Type[Warning]", ...]] ] = None, - match_expr: Optional[Union[str, "Pattern[str]"]] = None, + match_expr: Optional[Union[str, Pattern[str]]] = None, ) -> None: super().__init__()