Merge pull request #7837 from asottile/py36_union_pattern_match

py36+: remove workaround for Union[Pattern/Match] bug
This commit is contained in:
Anthony Sottile 2020-10-02 19:47:50 -07:00 committed by GitHub
commit ced0a52a87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 7 deletions

View File

@ -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`.

View File

@ -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

View File

@ -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__()