python-trio / trio

Trio – a friendly Python library for async concurrency and I/O
https://trio.readthedocs.io
Other
6.12k stars 335 forks source link

`sleep_forever` should be typed NoReturn #3095

Closed Redoubts closed 2 days ago

Redoubts commented 5 days ago

I think this would be more correct? the trio-typing stubs did this: https://github.com/python-trio/trio-typing/blob/c7d97072e630cced81cb8a7bb30c0707f1a5d235/trio-stubs/__init__.pyi#L198

A5rocks commented 5 days ago

Good catch! Feel free to make a PR.

TeamSpen210 commented 5 days ago

This is definitely correct, but I did notice a slight issue. It seems PyCharm has a bug where context managers won't be taken into account for unreachability. So the common case of a cancel-scope around sleep_forever will give spurious unreachable warnings.

Not sure if that is sufficient to prevent changing this.

CoolCat467 commented 4 days ago

I personally don't think we should avoid changing this just because an IDE's builtin type checker has bugs. If the type checker was separate from the IDE that might be a different story, but I'm sure they can fix this eventually.