Closed TeamSpen210 closed 1 week ago
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 99.63%. Comparing base (
451393a
) to head (87451f5
). Report is 2 commits behind head on master.
Seems RaisesGroup
needs to be Any
right now, otherwise a bunch of type-tests break for Pyright. @jakkdl looks like it might not actually be inferring the generic, and previously I think it wasn't generic at all.
RaisesGroup
types are currently all sorts of messed up IMO, though we still have to wait on https://github.com/python/mypy/pull/16753 + a release of mypy before making them better...
Turns out the stuff necessary for RaisesGroup
-but-good is merged in mypy (in someone else's PR that touched inference)! After the next mypy release I'll take my chances on nicer typing. I don't think it's worth thinking too much about type var defaults for them right now.
Seems
RaisesGroup
needs to beAny
right now, otherwise a bunch of type-tests break for Pyright. @jakkdl looks like it might not actually be inferring the generic, and previously I think it wasn't generic at all.
could you maybe add a test (with type: ignore
or pyright: ignore
) that demonstrates the issue, even without default?
Looking at the error again, it might just be the mypy issue we're already aware of. I'll just revert the changes to RaiseGroup
for this PR.
It would be nice to have some addition to the typing tests that demonstrate what has changed.
def check_typevar_default(e: Matcher) -> None:
assert e.exception_type is not None
f = e.exception_type()
# this would previously pass, as `f` would be `Any`
f = 5 # type: ignore[assignment]
def check_typevar_default_explicit(e: Matcher) -> None:
assert_type(e.exception_type, Optional[type[BaseException]])
Other than that it looks great.
This causes annotations to default to
TaskStatus[None]
,RaisesGroup[BaseException]
andMatcher[BaseException]
, instead ofAny
._socket
could also use this to makeSocketType
generic overAddressFormat
, but I'm not really sure how that should behave.