Skip to content

Commit 2b35103

Browse files
authored
Merge branch 'main' into fix/issue-3409
2 parents 56fce55 + 7d09fc6 commit 2b35103

14 files changed

Lines changed: 77 additions & 72 deletions

.pre-commit-config.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,33 +20,33 @@ repos:
2020
- id: sort-simple-yaml
2121
files: .pre-commit-config.yaml
2222
- repo: https://github.com/psf/black-pre-commit-mirror
23-
rev: 26.1.0
23+
rev: 26.3.1
2424
hooks:
2525
- id: black
2626
- repo: https://github.com/astral-sh/ruff-pre-commit
27-
rev: v0.15.4
27+
rev: v0.15.9
2828
hooks:
2929
- id: ruff-check
3030
types: [file]
3131
types_or: [python, pyi, toml]
3232
args: ["--show-fixes"]
3333
- repo: https://github.com/codespell-project/codespell
34-
rev: v2.4.1
34+
rev: v2.4.2
3535
hooks:
3636
- id: codespell
3737
additional_dependencies:
3838
# tomli needed on 3.10. tomllib is available in stdlib on 3.11+
3939
- tomli
4040
- repo: https://github.com/adhtruong/mirrors-typos
41-
rev: v1.44.0
41+
rev: v1.45.0
4242
hooks:
4343
- id: typos
4444
- repo: https://github.com/sphinx-contrib/sphinx-lint
4545
rev: v1.0.2
4646
hooks:
4747
- id: sphinx-lint
4848
- repo: https://github.com/woodruffw/zizmor-pre-commit
49-
rev: v1.22.0
49+
rev: v1.23.1
5050
hooks:
5151
- id: zizmor
5252
- repo: local
@@ -73,7 +73,7 @@ repos:
7373
additional_dependencies: ["pyyaml"]
7474
files: ^(test-requirements\.txt)|(\.pre-commit-config\.yaml)$
7575
- repo: https://github.com/astral-sh/uv-pre-commit
76-
rev: 0.10.7
76+
rev: 0.11.3
7777
hooks:
7878
# Compile requirements
7979
- id: pip-compile

docs-requirements.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# uv pip compile --universal --python-version=3.11 docs-requirements.in -o docs-requirements.txt
33
alabaster==1.0.0
44
# via sphinx
5-
attrs==25.4.0
5+
attrs==26.1.0
66
# via
77
# -r docs-requirements.in
88
# outcome
@@ -16,15 +16,15 @@ cffi==2.0.0 ; os_name == 'nt' or platform_python_implementation != 'PyPy'
1616
# via
1717
# -r docs-requirements.in
1818
# cryptography
19-
charset-normalizer==3.4.4
19+
charset-normalizer==3.4.6
2020
# via requests
2121
click==8.3.1
2222
# via towncrier
2323
colorama==0.4.6 ; sys_platform == 'win32'
2424
# via
2525
# click
2626
# sphinx
27-
cryptography==46.0.5
27+
cryptography==46.0.6
2828
# via pyopenssl
2929
docutils==0.22.4
3030
# via
@@ -36,7 +36,7 @@ idna==3.11
3636
# via
3737
# -r docs-requirements.in
3838
# requests
39-
imagesize==1.4.1
39+
imagesize==2.0.0
4040
# via sphinx
4141
immutables==0.21
4242
# via -r docs-requirements.in
@@ -53,11 +53,11 @@ packaging==26.0
5353
# via sphinx
5454
pycparser==3.0 ; (implementation_name != 'PyPy' and os_name == 'nt') or (implementation_name != 'PyPy' and platform_python_implementation != 'PyPy')
5555
# via cffi
56-
pygments==2.19.2
56+
pygments==2.20.0
5757
# via sphinx
58-
pyopenssl==25.3.0
58+
pyopenssl==26.0.0
5959
# via -r docs-requirements.in
60-
requests==2.32.5
60+
requests==2.33.1
6161
# via sphinx
6262
roman-numerals==4.1.0
6363
# via sphinx

docs/source/index.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ Vital statistics:
8686
contributing.rst
8787
releasing.rst
8888
code-of-conduct.rst
89-
genindex
89+
90+
.. once https://github.com/sphinx-doc/sphinx/issues/13733 is merged, add `genindex` above
9091
9192
====================
9293
Indices and tables

newsfragments/3403.deprecated.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Trying to use absolute deadlines on a `trio.CancelScope` constructed
2+
with a relative deadline now raises, after being deprecated since Trio
3+
0.27.0.
4+
5+
To switch a cancel scope from being relative to absolute, replace the
6+
`trio.CancelScope` object instead of trying to mutate it.

src/trio/_core/_local.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,11 @@ def get(self, default: T | type[_NoValue] = _NoValue) -> T:
4949
raise RuntimeError("Cannot be used outside of a run context") from None
5050
except KeyError:
5151
# contextvars consistency
52-
# `type: ignore` awaiting https://github.com/python/mypy/issues/15553 to be fixed & released
5352
if default is not _NoValue:
54-
return default # type: ignore[return-value]
53+
return default
5554

5655
if self._default is not _NoValue:
57-
return self._default # type: ignore[return-value]
56+
return self._default
5857

5958
raise LookupError(self) from None
6059

src/trio/_core/_run.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -808,13 +808,9 @@ def deadline(self) -> float:
808808
"""
809809
if self._relative_deadline != inf:
810810
assert self._deadline == inf
811-
warnings.warn(
812-
DeprecationWarning(
813-
"unentered relative cancel scope does not have an absolute deadline. Use `.relative_deadline`",
814-
),
815-
stacklevel=2,
811+
raise RuntimeError(
812+
"Unentered relative cancel scope does not have an absolute deadline."
816813
)
817-
return current_time() + self._relative_deadline
818814
return self._deadline
819815

820816
@deadline.setter
@@ -823,13 +819,9 @@ def deadline(self, new_deadline: float) -> None:
823819
raise ValueError("deadline must not be NaN")
824820
if self._relative_deadline != inf:
825821
assert self._deadline == inf
826-
warnings.warn(
827-
DeprecationWarning(
828-
"unentered relative cancel scope does not have an absolute deadline. Transforming into an absolute cancel scope. First set `.relative_deadline = math.inf` if you do want an absolute cancel scope.",
829-
),
830-
stacklevel=2,
822+
raise RuntimeError(
823+
"Unentered relative cancel scope does not have an absolute deadline."
831824
)
832-
self._relative_deadline = inf
833825
with self._might_change_registered_deadline():
834826
self._deadline = float(new_deadline)
835827

@@ -852,7 +844,7 @@ def relative_deadline(self) -> float:
852844
elif self._deadline != inf:
853845
assert self._relative_deadline == inf
854846
raise RuntimeError(
855-
"unentered non-relative cancel scope does not have a relative deadline",
847+
"Unentered non-relative cancel scope does not have a relative deadline",
856848
)
857849
return self._relative_deadline
858850

@@ -868,7 +860,7 @@ def relative_deadline(self, new_relative_deadline: float) -> None:
868860
elif self._deadline != inf:
869861
assert self._relative_deadline == inf
870862
raise RuntimeError(
871-
"unentered non-relative cancel scope does not have a relative deadline",
863+
"Unentered non-relative cancel scope does not have a relative deadline",
872864
)
873865
else:
874866
self._relative_deadline = new_relative_deadline

src/trio/_core/_tests/test_asyncgen.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,10 +306,12 @@ def test_delegation_to_existing_hooks() -> None:
306306

307307
def my_firstiter(agen: AsyncGenerator[object, NoReturn]) -> None:
308308
assert isinstance(agen, AsyncGeneratorType)
309+
assert agen.ag_frame is not None
309310
record.append("firstiter " + agen.ag_frame.f_locals["arg"])
310311

311312
def my_finalizer(agen: AsyncGenerator[object, NoReturn]) -> None:
312313
assert isinstance(agen, AsyncGeneratorType)
314+
assert agen.ag_frame is not None
313315
record.append("finalizer " + agen.ag_frame.f_locals["arg"])
314316

315317
async def example(arg: str) -> AsyncGenerator[int, None]:

src/trio/_path.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,9 @@ def __repr__(self) -> str:
263263
if sys.version_info >= (3, 13):
264264
full_match = _wrap_method(pathlib.Path.full_match)
265265

266+
# TODO: only allow this for Python <3.19.
266267
def as_uri(self) -> str:
267-
return pathlib.Path.as_uri(self)
268+
return pathlib.PurePath.as_uri(self)
268269

269270

270271
if Path.relative_to.__doc__: # pragma: no branch

src/trio/_socket.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ def fromshare(info: bytes) -> SocketType:
338338
else:
339339
FamilyDefault: None = None
340340
FamilyT: TypeAlias = int | AddressFamily | None
341-
TypeT: TypeAlias = _stdlib_socket.socket | int
341+
TypeT: TypeAlias = _stdlib_socket.SocketKind | int
342342

343343

344344
@_wraps(_stdlib_socket.socketpair, assigned=(), updated=())

src/trio/_tests/test_exports.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ def _ensure_mypy_cache_updated() -> None:
5252
"--config-file=",
5353
"--cache-dir=./.mypy_cache",
5454
"--no-error-summary",
55+
# TODO: update our tests to use the exposed APIs
56+
# instead of reading JSON... or use dmypy?
57+
"--no-fixed-format-cache",
58+
"--no-sqlite-cache",
5559
"-c",
5660
"import trio",
5761
],

0 commit comments

Comments
 (0)