Add typing for _highlevel_open_tcp_listeners.py#2724
Add typing for _highlevel_open_tcp_listeners.py#2724jakkdl merged 27 commits intopython-trio:masterfrom
_highlevel_open_tcp_listeners.py#2724Conversation
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 |
TeamSpen210
left a comment
There was a problem hiding this comment.
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. |
jakkdl
left a comment
There was a problem hiding this comment.
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. |
jakkdl
left a comment
There was a problem hiding this comment.
Task -> TaskStatus as TeamSpen pointed out, but otherwise mostly good. No need for a re-review from me.
TeamSpen210
left a comment
There was a problem hiding this comment.
Looks, good, except for one minor quibble.
| from . import socket as tsocket | ||
|
|
||
| if TYPE_CHECKING: | ||
| from trio.lowlevel import TaskStatus |
There was a problem hiding this comment.
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.
Does not need to be guarded as far as I am aware
There was a problem hiding this comment.
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.
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_statusin theserve_tcpfunction. 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.