Skip to content

Commit 287d690

Browse files
committed
Merge remote-tracking branch 'origin/main' into ruff-preview-mode
2 parents fe334dc + 498325d commit 287d690

File tree

6 files changed

+40
-23
lines changed

6 files changed

+40
-23
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ repos:
2424
hooks:
2525
- id: black
2626
- repo: https://github.com/astral-sh/ruff-pre-commit
27-
rev: v0.6.7
27+
rev: v0.6.8
2828
hooks:
2929
- id: ruff
3030
types: [file]

docs-requirements.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ beautifulsoup4==4.12.3
1212
# via sphinx-codeautolink
1313
certifi==2024.8.30
1414
# via requests
15-
cffi==1.17.0 ; platform_python_implementation != 'PyPy' or os_name == 'nt'
15+
cffi==1.17.1 ; platform_python_implementation != 'PyPy' or os_name == 'nt'
1616
# via
1717
# -r docs-requirements.in
1818
# cryptography
@@ -24,15 +24,15 @@ colorama==0.4.6 ; sys_platform == 'win32' or platform_system == 'Windows'
2424
# via
2525
# click
2626
# sphinx
27-
cryptography==43.0.0
27+
cryptography==43.0.1
2828
# via pyopenssl
2929
docutils==0.20.1
3030
# via
3131
# sphinx
3232
# sphinx-rtd-theme
3333
exceptiongroup==1.2.2
3434
# via -r docs-requirements.in
35-
idna==3.8
35+
idna==3.10
3636
# via
3737
# -r docs-requirements.in
3838
# requests
@@ -77,7 +77,7 @@ sphinx==7.4.7
7777
# sphinxcontrib-trio
7878
sphinx-codeautolink==0.15.2
7979
# via -r docs-requirements.in
80-
sphinx-hoverxref==1.4.0
80+
sphinx-hoverxref==1.4.1
8181
# via -r docs-requirements.in
8282
sphinx-rtd-theme==2.0.0
8383
# via -r docs-requirements.in
@@ -102,5 +102,5 @@ sphinxcontrib-trio==1.1.2
102102
# via -r docs-requirements.in
103103
towncrier==24.8.0
104104
# via -r docs-requirements.in
105-
urllib3==2.2.2
105+
urllib3==2.2.3
106106
# via requests

newsfragments/3095.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Update :func:`trio.sleep_forever` to be `NoReturn`.

src/trio/_tests/test_timeouts.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,20 @@ async def sleep_3() -> None:
8686
await check_takes_about(sleep_3, TARGET)
8787

8888

89+
async def test_cannot_wake_sleep_forever() -> None:
90+
# Test an error occurs if you manually wake sleep_forever().
91+
task = trio.lowlevel.current_task()
92+
93+
async def wake_task() -> None:
94+
await trio.lowlevel.checkpoint()
95+
trio.lowlevel.reschedule(task, outcome.Value(None))
96+
97+
async with trio.open_nursery() as nursery:
98+
nursery.start_soon(wake_task)
99+
with pytest.raises(RuntimeError):
100+
await trio.sleep_forever()
101+
102+
89103
class TimeoutScope(Protocol):
90104
def __call__(self, seconds: float, *, shield: bool) -> trio.CancelScope: ...
91105

src/trio/_timeouts.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import math
44
import sys
55
from contextlib import contextmanager
6-
from typing import TYPE_CHECKING
6+
from typing import TYPE_CHECKING, NoReturn
77

88
import trio
99

@@ -58,13 +58,14 @@ def move_on_after(
5858
)
5959

6060

61-
async def sleep_forever() -> None:
61+
async def sleep_forever() -> NoReturn:
6262
"""Pause execution of the current task forever (or until cancelled).
6363
6464
Equivalent to calling ``await sleep(math.inf)``.
6565
6666
"""
6767
await trio.lowlevel.wait_task_rescheduled(lambda _: trio.lowlevel.Abort.SUCCEEDED)
68+
raise RuntimeError("Should never have been rescheduled!")
6869

6970

7071
async def sleep_until(deadline: float) -> None:

test-requirements.txt

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ black==24.8.0 ; implementation_name == 'cpython'
1818
# via -r test-requirements.in
1919
certifi==2024.8.30
2020
# via requests
21-
cffi==1.17.0 ; platform_python_implementation != 'PyPy' or os_name == 'nt'
21+
cffi==1.17.1 ; platform_python_implementation != 'PyPy' or os_name == 'nt'
2222
# via
2323
# -r test-requirements.in
2424
# cryptography
@@ -36,28 +36,28 @@ colorama==0.4.6 ; (implementation_name != 'cpython' and sys_platform == 'win32')
3636
# sphinx
3737
coverage==7.6.1
3838
# via -r test-requirements.in
39-
cryptography==43.0.0
39+
cryptography==43.0.1
4040
# via
4141
# -r test-requirements.in
4242
# pyopenssl
4343
# trustme
4444
# types-pyopenssl
45-
dill==0.3.8
45+
dill==0.3.9
4646
# via pylint
4747
docutils==0.20.1
4848
# via sphinx
4949
exceptiongroup==1.2.2 ; python_full_version < '3.11'
5050
# via
5151
# -r test-requirements.in
5252
# pytest
53-
idna==3.8
53+
idna==3.10
5454
# via
5555
# -r test-requirements.in
5656
# requests
5757
# trustme
5858
imagesize==1.4.1
5959
# via sphinx
60-
importlib-metadata==8.4.0 ; python_full_version < '3.10'
60+
importlib-metadata==8.5.0 ; python_full_version < '3.10'
6161
# via sphinx
6262
iniconfig==2.0.0
6363
# via pytest
@@ -91,7 +91,7 @@ parso==0.8.4 ; implementation_name == 'cpython'
9191
# via jedi
9292
pathspec==0.12.1 ; implementation_name == 'cpython'
9393
# via black
94-
platformdirs==4.2.2
94+
platformdirs==4.3.6
9595
# via
9696
# black
9797
# pylint
@@ -105,15 +105,15 @@ pylint==3.2.7
105105
# via -r test-requirements.in
106106
pyopenssl==24.2.1
107107
# via -r test-requirements.in
108-
pyright==1.1.381
108+
pyright==1.1.382.post1
109109
# via -r test-requirements.in
110-
pytest==8.3.2
110+
pytest==8.3.3
111111
# via -r test-requirements.in
112-
pytz==2024.1 ; python_full_version < '3.9'
112+
pytz==2024.2 ; python_full_version < '3.9'
113113
# via babel
114114
requests==2.32.3
115115
# via sphinx
116-
ruff==0.6.6
116+
ruff==0.6.8
117117
# via -r test-requirements.in
118118
sniffio==1.3.1
119119
# via -r test-requirements.in
@@ -149,11 +149,11 @@ types-cffi==1.16.0.20240331
149149
# via
150150
# -r test-requirements.in
151151
# types-pyopenssl
152-
types-docutils==0.21.0.20240724
152+
types-docutils==0.21.0.20240907
153153
# via -r test-requirements.in
154154
types-pyopenssl==24.1.0.20240722
155155
# via -r test-requirements.in
156-
types-setuptools==74.0.0.20240831
156+
types-setuptools==75.1.0.20240917
157157
# via types-cffi
158158
typing-extensions==4.12.2
159159
# via
@@ -162,9 +162,10 @@ typing-extensions==4.12.2
162162
# black
163163
# mypy
164164
# pylint
165-
urllib3==2.2.2
165+
# pyright
166+
urllib3==2.2.3
166167
# via requests
167-
uv==0.4.1
168+
uv==0.4.17
168169
# via -r test-requirements.in
169-
zipp==3.20.1 ; python_full_version < '3.10'
170+
zipp==3.20.2 ; python_full_version < '3.10'
170171
# via importlib-metadata

0 commit comments

Comments
 (0)