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

trio.sleep_forever should be NoReturn #3096

Closed Redoubts closed 2 days ago

Redoubts commented 5 days ago

Fixes #3095

codecov[bot] commented 5 days ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 99.58%. Comparing base (4e979bf) to head (e5f38f3). Report is 1 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #3096 +/- ## ======================================= Coverage 99.58% 99.58% ======================================= Files 121 121 Lines 17992 18002 +10 Branches 3245 3248 +3 ======================================= + Hits 17917 17927 +10 Misses 52 52 Partials 23 23 ``` | [Files with missing lines](https://app.codecov.io/gh/python-trio/trio/pull/3096?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-trio) | Coverage Δ | | |---|---|---| | [src/trio/\_tests/test\_timeouts.py](https://app.codecov.io/gh/python-trio/trio/pull/3096?src=pr&el=tree&filepath=src%2Ftrio%2F_tests%2Ftest_timeouts.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-trio#diff-c3JjL3RyaW8vX3Rlc3RzL3Rlc3RfdGltZW91dHMucHk=) | `98.56% <100.00%> (+0.09%)` | :arrow_up: | | [src/trio/\_timeouts.py](https://app.codecov.io/gh/python-trio/trio/pull/3096?src=pr&el=tree&filepath=src%2Ftrio%2F_timeouts.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-trio#diff-c3JjL3RyaW8vX3RpbWVvdXRzLnB5) | `100.00% <100.00%> (ø)` | |
TeamSpen210 commented 5 days ago

Well, actually mypy is correct. If someone did trio.lowlevel.reschedule(), sleep_forever() could succeed. That's totally incorrect to do of course. We could just add a raise TrioInternalError("Should never have been rescheduled!") after the await, which will quiet the type error and make sure you can't do that any more.

trio-bot[bot] commented 2 days ago

Hey @Redoubts, it looks like that was the first time we merged one of your PRs! Thanks so much! :tada: :birthday:

If you want to keep contributing, we'd love to have you. So, I just sent you an invitation to join the python-trio organization on Github! If you accept, then here's what will happen:

If you want to read more, here's the relevant section in our contributing guide.

Alternatively, you're free to decline or ignore the invitation. You'll still be able to contribute as much or as little as you like, and I won't hassle you about joining again. But if you ever change your mind, just let us know and we'll send another invitation. We'd love to have you, but more importantly we want you to do whatever's best for you.

If you have any questions, well... I am just a humble Python script, so I probably can't help. But please do post a comment here, or in our chat, or on our forum, whatever's easiest, and someone will help you out!