-
-
Notifications
You must be signed in to change notification settings - Fork 351
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use Typevar defaults for TaskStatus
and Matcher
#3019
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #3019 +/- ##
=======================================
Coverage 99.63% 99.63%
=======================================
Files 120 120
Lines 17863 17865 +2
Branches 3217 3216 -1
=======================================
+ Hits 17798 17800 +2
Misses 46 46
Partials 19 19
|
TaskStatus
, RaisesGroup
and Matcher
TaskStatus
and Matcher
Seems |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code makes sense, though I'm not sure either RaisesGroup
or (especially) _ExceptionInfo
is used in type hints enough to make typevar defaults make sense. Definitely for TaskStatus
though.
Turns out the stuff necessary for |
could you maybe add a test (with |
Looking at the error again, it might just be the mypy issue we're already aware of. I'll just revert the changes to |
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.