-
-
Notifications
You must be signed in to change notification settings - Fork 343
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
Add some low-effort type annotations #2477
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #2477 +/- ##
==========================================
+ Coverage 92.46% 93.50% +1.04%
==========================================
Files 118 118
Lines 16327 16336 +9
Branches 3156 3157 +1
==========================================
+ Hits 15096 15275 +179
+ Misses 1103 955 -148
+ Partials 128 106 -22
|
Thank you for reviving this effort! Previous attempts are https://github.com/python-trio/trio-typing, #1873 and #2208. A gradual approach is certainly possible: https://sethmlarson.dev/blog/tests-arent-enough-case-study-after-adding-types-to-urllib3. But I think you have to make it work file by file using an allowlist, as done for urllib3. Case in point, the mypy check is failing for this pull request. |
@pquentin We can probably figure out the exact mypy config as we go. The reason it failed was due to the I've made mypy succeed now, but I ended up adding some uncovered lines in the process. |
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 reordering of imports is unfortunate, but this looks good overall.
Unfortunately compatibility with typing
is a bit cursed: from __future__ import annotations
is in limbo (note the lack of resolution for 3.12). If that ever gets removed, we need to make sure we use that version's types at runtime -- of course, it shouldn't be. It's likely that we'll have to change it to co_annotations
or similar soon. We'll just have to take this as we can. A good next step would be adding mypy
to ci.sh
to run it on every platform we test (other than PyPy ones, of course).
This PR adds some uncontroversial annotations to the central
trio.run
method. From my perspective, it is mainly intended as an experiment into whether a gradual, opportunistic approach to adding types to this project is feasible.