diff --git a/docs-requirements.txt b/docs-requirements.txt index 8274c1ec5..dbd3ff69a 100644 --- a/docs-requirements.txt +++ b/docs-requirements.txt @@ -2,7 +2,7 @@ # uv pip compile --universal --python-version=3.11 docs-requirements.in -o docs-requirements.txt alabaster==1.0.0 # via sphinx -attrs==25.4.0 +attrs==26.1.0 # via # -r docs-requirements.in # outcome @@ -24,7 +24,7 @@ colorama==0.4.6 ; sys_platform == 'win32' # via # click # sphinx -cryptography==46.0.5 +cryptography==46.0.6 # via pyopenssl docutils==0.22.4 # via @@ -53,11 +53,11 @@ packaging==26.0 # via sphinx pycparser==3.0 ; (implementation_name != 'PyPy' and os_name == 'nt') or (implementation_name != 'PyPy' and platform_python_implementation != 'PyPy') # via cffi -pygments==2.19.2 +pygments==2.20.0 # via sphinx pyopenssl==26.0.0 # via -r docs-requirements.in -requests==2.32.5 +requests==2.33.1 # via sphinx roman-numerals==4.1.0 # via sphinx diff --git a/src/trio/_core/_local.py b/src/trio/_core/_local.py index fff1234f5..21bb913cd 100644 --- a/src/trio/_core/_local.py +++ b/src/trio/_core/_local.py @@ -49,12 +49,11 @@ def get(self, default: T | type[_NoValue] = _NoValue) -> T: raise RuntimeError("Cannot be used outside of a run context") from None except KeyError: # contextvars consistency - # `type: ignore` awaiting https://github.com/python/mypy/issues/15553 to be fixed & released if default is not _NoValue: - return default # type: ignore[return-value] + return default if self._default is not _NoValue: - return self._default # type: ignore[return-value] + return self._default raise LookupError(self) from None diff --git a/src/trio/_core/_tests/test_asyncgen.py b/src/trio/_core/_tests/test_asyncgen.py index 91ca0250a..f9c190d49 100644 --- a/src/trio/_core/_tests/test_asyncgen.py +++ b/src/trio/_core/_tests/test_asyncgen.py @@ -306,10 +306,12 @@ def test_delegation_to_existing_hooks() -> None: def my_firstiter(agen: AsyncGenerator[object, NoReturn]) -> None: assert isinstance(agen, AsyncGeneratorType) + assert agen.ag_frame is not None record.append("firstiter " + agen.ag_frame.f_locals["arg"]) def my_finalizer(agen: AsyncGenerator[object, NoReturn]) -> None: assert isinstance(agen, AsyncGeneratorType) + assert agen.ag_frame is not None record.append("finalizer " + agen.ag_frame.f_locals["arg"]) async def example(arg: str) -> AsyncGenerator[int, None]: diff --git a/src/trio/_path.py b/src/trio/_path.py index 21e33eaae..7376c529e 100644 --- a/src/trio/_path.py +++ b/src/trio/_path.py @@ -263,8 +263,9 @@ def __repr__(self) -> str: if sys.version_info >= (3, 13): full_match = _wrap_method(pathlib.Path.full_match) + # TODO: only allow this for Python <3.19. def as_uri(self) -> str: - return pathlib.Path.as_uri(self) + return pathlib.PurePath.as_uri(self) if Path.relative_to.__doc__: # pragma: no branch diff --git a/src/trio/_socket.py b/src/trio/_socket.py index 68bbd4b6b..504874553 100644 --- a/src/trio/_socket.py +++ b/src/trio/_socket.py @@ -338,7 +338,7 @@ def fromshare(info: bytes) -> SocketType: else: FamilyDefault: None = None FamilyT: TypeAlias = int | AddressFamily | None - TypeT: TypeAlias = _stdlib_socket.socket | int + TypeT: TypeAlias = _stdlib_socket.SocketKind | int @_wraps(_stdlib_socket.socketpair, assigned=(), updated=()) diff --git a/src/trio/_tests/test_exports.py b/src/trio/_tests/test_exports.py index 0414d4342..0e978b4dc 100644 --- a/src/trio/_tests/test_exports.py +++ b/src/trio/_tests/test_exports.py @@ -52,6 +52,10 @@ def _ensure_mypy_cache_updated() -> None: "--config-file=", "--cache-dir=./.mypy_cache", "--no-error-summary", + # TODO: update our tests to use the exposed APIs + # instead of reading JSON... or use dmypy? + "--no-fixed-format-cache", + "--no-sqlite-cache", "-c", "import trio", ], diff --git a/src/trio/_tests/test_path.py b/src/trio/_tests/test_path.py index 9fe3920df..82e8c548c 100644 --- a/src/trio/_tests/test_path.py +++ b/src/trio/_tests/test_path.py @@ -2,6 +2,7 @@ import os import pathlib +import sys from typing import TYPE_CHECKING import pytest @@ -230,6 +231,9 @@ async def test_globmethods(path: trio.Path) -> None: assert entries == {"_bar.txt", "bar.txt"} +@pytest.mark.xfail( + sys.version_info >= (3, 14), reason="we need to update `as_uri` to use Path.as_uri" +) async def test_as_uri(path: trio.Path) -> None: path = await path.parent.resolve() diff --git a/src/trio/_util.py b/src/trio/_util.py index 8c10362f9..bae6608d8 100644 --- a/src/trio/_util.py +++ b/src/trio/_util.py @@ -298,7 +298,8 @@ def name_asyncgen(agen: AsyncGeneratorType[object, NoReturn]) -> str: if not hasattr(agen, "ag_code"): # pragma: no cover return repr(agen) try: - module = agen.ag_frame.f_globals["__name__"] + # `agen.ag_frame` can be None, but we catch AttributeError. + module = agen.ag_frame.f_globals["__name__"] # type: ignore[union-attr] except (AttributeError, KeyError): module = f"<{agen.ag_code.co_filename}>" try: diff --git a/test-requirements.txt b/test-requirements.txt index 2c1e2f880..89dde8663 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -8,7 +8,7 @@ astroid==4.0.4 # via pylint async-generator==1.10 # via -r test-requirements.in -attrs==25.4.0 +attrs==26.1.0 # via # -r test-requirements.in # outcome @@ -38,7 +38,7 @@ colorama==0.4.6 ; sys_platform == 'win32' # sphinx coverage==7.13.5 # via -r test-requirements.in -cryptography==46.0.5 +cryptography==46.0.6 # via # -r test-requirements.in # pyopenssl @@ -83,7 +83,7 @@ markupsafe==3.0.3 # via jinja2 mccabe==0.7.0 # via pylint -mypy==1.19.1 ; implementation_name == 'cpython' +mypy==1.20.0 ; implementation_name == 'cpython' # via -r test-requirements.in mypy-extensions==1.1.0 # via @@ -119,7 +119,7 @@ pre-commit==4.5.1 # via -r test-requirements.in pycparser==3.0 ; (implementation_name != 'PyPy' and os_name == 'nt') or (implementation_name != 'PyPy' and platform_python_implementation != 'PyPy') # via cffi -pygments==2.19.2 +pygments==2.20.0 # via # pytest # sphinx @@ -131,13 +131,13 @@ pyright==1.1.408 # via -r test-requirements.in pytest==9.0.2 # via -r test-requirements.in -python-discovery==1.2.0 +python-discovery==1.2.1 # via virtualenv pytokens==0.4.1 ; implementation_name == 'cpython' # via black pyyaml==6.0.3 # via pre-commit -requests==2.32.5 +requests==2.33.1 # via sphinx roman-numerals==4.1.0 ; python_full_version >= '3.11' # via sphinx @@ -167,7 +167,7 @@ sphinxcontrib-qthelp==2.0.0 # via sphinx sphinxcontrib-serializinghtml==2.0.0 # via sphinx -tomli==2.4.0 ; python_full_version < '3.11' +tomli==2.4.1 ; python_full_version < '3.11' # via # black # mypy @@ -182,7 +182,7 @@ types-cffi==2.0.0.20260316 # via # -r test-requirements.in # types-pyopenssl -types-docutils==0.22.3.20260316 +types-docutils==0.22.3.20260322 # via -r test-requirements.in types-pyopenssl==24.1.0.20240722 # via -r test-requirements.in