Skip to content

Commit

Permalink
add docstring to AbstractMatcher.matches to satisfy pyright --verifyt…
Browse files Browse the repository at this point in the history
…ypes
  • Loading branch information
jakkdl committed Jan 13, 2025
1 parent 0cc3968 commit 561660b
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/trio/testing/_raises_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,10 @@ def _check_match(self, e: BaseException) -> bool:
@abstractmethod
def matches(
self: AbstractMatcher[BaseExcT_1], exc_val: BaseException
) -> TypeGuard[BaseExcT_1]: ...
) -> TypeGuard[BaseExcT_1]:
"""Check if an exception matches the requirements of this AbstractMatcher.
If it fails, `AbstractMatcher.fail_reason` should be set.
"""


@final
Expand Down Expand Up @@ -572,16 +575,13 @@ def __init__(
self.is_baseexceptiongroup |= exc.is_baseexceptiongroup
exc._nested = True
elif isinstance(exc, Matcher):
if exc.exception_type is not None:
# Matcher __init__ assures it's a subclass of BaseException
self.is_baseexceptiongroup |= not issubclass(
exc.exception_type,
Exception,
)
exc._nested = True
# The Matcher could match BaseExceptions through the other arguments
# but `self.is_baseexceptiongroup` is only used for printing.
if exc.exception_type is None:
continue
# Matcher __init__ assures it's a subclass of BaseException
self.is_baseexceptiongroup |= not issubclass(
exc.exception_type,
Exception,
)
elif isinstance(exc, type) and issubclass(exc, BaseException):
self.is_baseexceptiongroup |= not issubclass(exc, Exception)
else:
Expand Down

0 comments on commit 561660b

Please sign in to comment.