Skip to content

Commit

Permalink
Merge pull request #7837 from asottile/py36_union_pattern_match
Browse files Browse the repository at this point in the history
py36+: remove workaround for Union[Pattern/Match] bug
  • Loading branch information
asottile committed Oct 3, 2020
2 parents 2c7b7d8 + e622cb7 commit ced0a52
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/_pytest/_code/code.py
Expand Up @@ -625,7 +625,7 @@ def getrepr(
)
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`.
Expand Down
4 changes: 2 additions & 2 deletions src/_pytest/python_api.py
Expand Up @@ -562,7 +562,7 @@ def _is_numpy_array(obj: object) -> bool:
def raises(
expected_exception: Union["Type[_E]", Tuple["Type[_E]", ...]],
*,
match: "Optional[Union[str, Pattern[str]]]" = ...
match: Optional[Union[str, Pattern[str]]] = ...
) -> "RaisesContext[_E]":
...

Expand Down Expand Up @@ -740,7 +740,7 @@ def __init__(
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
Expand Down
8 changes: 4 additions & 4 deletions src/_pytest/recwarn.py
Expand Up @@ -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":
...

Expand Down Expand Up @@ -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":
...

Expand All @@ -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.
Expand Down Expand Up @@ -236,7 +236,7 @@ def __init__(
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__()

Expand Down

0 comments on commit ced0a52

Please sign in to comment.