-
-
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 typing for _highlevel_open_tcp_listeners.py
#2724
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #2724 +/- ##
=======================================
Coverage 98.90% 98.90%
=======================================
Files 113 113
Lines 16669 16683 +14
Branches 3021 3025 +4
=======================================
+ Hits 16487 16501 +14
Misses 125 125
Partials 57 57
|
FYI I think |
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.
A few things that aren't quite right. verify_types.json
is a bit picky, it doesn't give the same results for me either.
#2699 tox would help here. |
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.
Update pyproject.toml
to add this file to the list of files that has increased strictness.
Interesting, Windows pypy 3.9 nightly x64 failed with a segfault from the tests script: https://github.com/python-trio/trio/actions/runs/5705575738/job/15460400267?pr=2724 |
it does that every now and then in my experience - no clue why. It's always been fixed by rerunning for me, but somebody should maybe open an issue and/or try to investigate the flakiness. |
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.
Task
-> TaskStatus
as TeamSpen pointed out, but otherwise mostly good. No need for a re-review from me.
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.
Looks, good, except for one minor quibble.
|
||
import trio | ||
|
||
from . import socket as tsocket | ||
|
||
if TYPE_CHECKING: | ||
from trio.lowlevel import TaskStatus |
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.
Does this import need to be guarded (due to import cycles), or can it be a real import? It's probably better to just import if we can, so that this can be evaluated at runtime.
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.
Does not need to be guarded as far as I am aware
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.
Reverted in 4a9b024
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.
This is kinda up in the air, I'd love it if we definitively resolved it and added a CI check that made usage consistent and saved review cycles. https://pypi.org/project/flake8-type-checking/
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.
I would suggest using https://pypi.org/project/ruff/ instead, it does the same thing and more but faster and with auto-fix support
Given the number of open typing PRs, I'm merging this one. Any minor problems can be addressed later if you want to bother going through it @A5rocks |
This PR adds type annotations to
_highlevel_open_tcp_listeners.py
.The only thing that might be a bit off is the type of
task_status
in theserve_tcp
function. I annotated it astrio.lowlevel.Task
, but I am not sure this is right.I would love feedback and any comments on how this could be improved to be more accurate.