Skip to content

Commit 8cb294f

Browse files
committed
okay actually for real for real rename reqs->parameters. update comments
1 parent dff6377 commit 8cb294f

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/trio/testing/_raises_group.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,8 @@ def _check_match(self, e: BaseException) -> bool:
251251
self._fail_reason += "\n Did you mean to `re.escape()` the regex?"
252252
return False
253253

254+
# TODO: when transitioning to pytest, harmonize Matcher and RaisesGroup
255+
# signatures. One names the parameter `exc_val` and the other `exception`
254256
@abstractmethod
255257
def matches(
256258
self: AbstractMatcher[BaseExcT_1], exc_val: BaseException
@@ -282,7 +284,7 @@ class Matcher(AbstractMatcher[MatchE]):
282284
# At least one of the three parameters must be passed.
283285
@overload
284286
def __init__(
285-
self: Matcher[MatchE],
287+
self,
286288
exception_type: type[MatchE],
287289
match: str | Pattern[str] = ...,
288290
check: Callable[[MatchE], bool] = ...,
@@ -616,20 +618,20 @@ def __enter__(self) -> ExceptionInfo[BaseExceptionGroup[BaseException]]:
616618
return self.excinfo
617619

618620
def __repr__(self) -> str:
619-
reqs = [
621+
parameters = [
620622
e.__name__ if isinstance(e, type) else repr(e)
621623
for e in self.expected_exceptions
622624
]
623625
if self.allow_unwrapped:
624-
reqs.append(f"allow_unwrapped={self.allow_unwrapped}")
626+
parameters.append(f"allow_unwrapped={self.allow_unwrapped}")
625627
if self.flatten_subgroups:
626-
reqs.append(f"flatten_subgroups={self.flatten_subgroups}")
628+
parameters.append(f"flatten_subgroups={self.flatten_subgroups}")
627629
if self.match is not None:
628630
# If no flags were specified, discard the redundant re.compile() here.
629-
reqs.append(f"match={_match_pattern(self.match)!r}")
631+
parameters.append(f"match={_match_pattern(self.match)!r}")
630632
if self.check is not None:
631-
reqs.append(f"check={repr_callable(self.check)}")
632-
return f"RaisesGroup({', '.join(reqs)})"
633+
parameters.append(f"check={repr_callable(self.check)}")
634+
return f"RaisesGroup({', '.join(parameters)})"
633635

634636
def _unroll_exceptions(
635637
self,
@@ -982,9 +984,9 @@ def set_result(self, expected: int, actual: int, result: str | None) -> None:
982984

983985
def get_result(self, expected: int, actual: int) -> str | None:
984986
res = self.results[actual][expected]
985-
assert res is not NotChecked
986-
# why doesn't mypy pick up on the above assert?
987-
return res # type: ignore[return-value]
987+
# mypy doesn't support `assert res is not NotChecked`
988+
assert not isinstance(res, type)
989+
return res
988990

989991
def has_result(self, expected: int, actual: int) -> bool:
990992
return self.results[actual][expected] is not NotChecked

0 commit comments

Comments
 (0)