diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6887e0cca..302966485 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -24,7 +24,7 @@ repos: hooks: - id: black - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.14.6 + rev: v0.14.7 hooks: - id: ruff-check types: [file] @@ -38,7 +38,7 @@ repos: # tomli needed on 3.10. tomllib is available in stdlib on 3.11+ - tomli - repo: https://github.com/adhtruong/mirrors-typos - rev: v1.39.2 + rev: v1.40.0 hooks: - id: typos - repo: https://github.com/sphinx-contrib/sphinx-lint @@ -46,7 +46,7 @@ repos: hooks: - id: sphinx-lint - repo: https://github.com/woodruffw/zizmor-pre-commit - rev: v1.16.3 + rev: v1.18.0 hooks: - id: zizmor - repo: local @@ -73,7 +73,7 @@ repos: additional_dependencies: ["pyyaml"] files: ^(test-requirements\.txt)|(\.pre-commit-config\.yaml)$ - repo: https://github.com/astral-sh/uv-pre-commit - rev: 0.9.11 + rev: 0.9.14 hooks: # Compile requirements - id: pip-compile diff --git a/docs-requirements.txt b/docs-requirements.txt index 4fcf0cd18..cb27b1c26 100644 --- a/docs-requirements.txt +++ b/docs-requirements.txt @@ -8,9 +8,9 @@ attrs==25.4.0 # outcome babel==2.17.0 # via sphinx -beautifulsoup4==4.14.2 +beautifulsoup4==4.14.3 # via sphinx-codeautolink -certifi==2025.10.5 +certifi==2025.11.12 # via requests cffi==2.0.0 ; os_name == 'nt' or platform_python_implementation != 'PyPy' # via @@ -18,7 +18,7 @@ cffi==2.0.0 ; os_name == 'nt' or platform_python_implementation != 'PyPy' # cryptography charset-normalizer==3.4.4 # via requests -click==8.3.0 +click==8.3.1 # via towncrier colorama==0.4.6 ; sys_platform == 'win32' # via @@ -30,7 +30,7 @@ docutils==0.21.2 # via # sphinx # sphinx-rtd-theme -exceptiongroup==1.3.0 +exceptiongroup==1.3.1 # via -r docs-requirements.in idna==3.11 # via diff --git a/src/trio/_core/_tests/test_asyncgen.py b/src/trio/_core/_tests/test_asyncgen.py index 8147a0e57..91ca0250a 100644 --- a/src/trio/_core/_tests/test_asyncgen.py +++ b/src/trio/_core/_tests/test_asyncgen.py @@ -221,13 +221,15 @@ async def async_main() -> None: saved.append(agen()) await saved[-1].asend(None) + ATTEMPT_AMOUNT = 50 + # Actually running into the edge case requires that the run_sync_soon task # execute in between the system nursery's closure and the strong-ification # of runner.asyncgens. There's about a 25% chance that it doesn't # (if the run_sync_soon task runs before init on one tick and after init # on the next tick); if we try enough times, we can make the chance of # failure as small as we want. - for _attempt in range(50): + for _ in range(ATTEMPT_AMOUNT): needs_retry = False record.clear() saved.clear() @@ -240,7 +242,7 @@ async def async_main() -> None: else: # pragma: no cover pytest.fail( "Didn't manage to hit the trailing_finalizer_asyncgens case " - f"despite trying {_attempt} times", + f"despite trying {ATTEMPT_AMOUNT} times", ) diff --git a/src/trio/_core/_tests/test_ki.py b/src/trio/_core/_tests/test_ki.py index a8d81ca02..cf37aae6d 100644 --- a/src/trio/_core/_tests/test_ki.py +++ b/src/trio/_core/_tests/test_ki.py @@ -164,7 +164,7 @@ def protected_manager() -> Iterator[None]: @pytest.mark.skipif(async_generator is None, reason="async_generator not installed") async def test_async_generator_agen_protection() -> None: @_core.enable_ki_protection - @async_generator # type: ignore[misc] # untyped generator + @async_generator # type: ignore[untyped-decorator] async def agen_protected1() -> None: # type: ignore[misc] # untyped generator assert _core.currently_ki_protected() try: @@ -173,7 +173,7 @@ async def agen_protected1() -> None: # type: ignore[misc] # untyped generator assert _core.currently_ki_protected() @_core.disable_ki_protection - @async_generator # type: ignore[misc] # untyped generator + @async_generator # type: ignore[untyped-decorator] async def agen_unprotected1() -> None: # type: ignore[misc] # untyped generator assert not _core.currently_ki_protected() try: @@ -182,7 +182,7 @@ async def agen_unprotected1() -> None: # type: ignore[misc] # untyped generator assert not _core.currently_ki_protected() # Swap the order of the decorators: - @async_generator # type: ignore[misc] # untyped generator + @async_generator # type: ignore[untyped-decorator] @_core.enable_ki_protection async def agen_protected2() -> None: # type: ignore[misc] # untyped generator assert _core.currently_ki_protected() @@ -191,7 +191,7 @@ async def agen_protected2() -> None: # type: ignore[misc] # untyped generator finally: assert _core.currently_ki_protected() - @async_generator # type: ignore[misc] # untyped generator + @async_generator # type: ignore[untyped-decorator] @_core.disable_ki_protection async def agen_unprotected2() -> None: # type: ignore[misc] # untyped generator assert not _core.currently_ki_protected() diff --git a/src/trio/_tests/test_exports.py b/src/trio/_tests/test_exports.py index 0f8158f37..10d71a9ff 100644 --- a/src/trio/_tests/test_exports.py +++ b/src/trio/_tests/test_exports.py @@ -175,6 +175,10 @@ def no_underscores(symbols: Iterable[str]) -> set[str]: completions = script.complete() static_names = no_underscores(c.name for c in completions) elif tool == "mypy": + if sys.implementation.name != "cpython": + # https://github.com/python/mypy/issues/20329 + pytest.skip("mypy does not support pypy") + if not RUN_SLOW: # pragma: no cover pytest.skip("use --run-slow to check against mypy") @@ -272,6 +276,10 @@ def no_hidden(symbols: Iterable[str]) -> set[str]: if tool == "jedi" and sys.implementation.name != "cpython": pytest.skip("jedi does not support pypy") + if tool == "mypy" and sys.implementation.name != "cpython": + # https://github.com/python/mypy/issues/20329 + pytest.skip("mypy does not support pypy") + if tool == "mypy": cache = Path.cwd() / ".mypy_cache" diff --git a/src/trio/_tests/test_path.py b/src/trio/_tests/test_path.py index 533ff94c5..9fe3920df 100644 --- a/src/trio/_tests/test_path.py +++ b/src/trio/_tests/test_path.py @@ -210,16 +210,16 @@ async def test_globmethods(path: trio.Path) -> None: await (path / "bar.dat").write_bytes(b"") # Path.glob - for _pattern, _results in { + for pattern, results in { "*.txt": {"bar.txt"}, "**/*.txt": {"_bar.txt", "bar.txt"}, }.items(): entries = set() - for entry in await path.glob(_pattern): + for entry in await path.glob(pattern): assert isinstance(entry, trio.Path) entries.add(entry.name) - assert entries == _results + assert entries == results # Path.rglob entries = set() diff --git a/src/trio/socket.py b/src/trio/socket.py index cfcb9943c..5375a1a67 100644 --- a/src/trio/socket.py +++ b/src/trio/socket.py @@ -26,9 +26,9 @@ # have: globals().update( { - _name: getattr(_stdlib_socket, _name) - for _name in _stdlib_socket.__all__ - if _name.isupper() and _name not in _bad_symbols + name: getattr(_stdlib_socket, name) + for name in _stdlib_socket.__all__ + if name.isupper() and name not in _bad_symbols }, ) diff --git a/test-requirements.in b/test-requirements.in index b16a2b5d6..272da6a34 100644 --- a/test-requirements.in +++ b/test-requirements.in @@ -11,7 +11,7 @@ cryptography>=41.0.0 # cryptography<41 segfaults on pypy3.10 # Tools black; implementation_name == "cpython" -mypy +mypy; implementation_name == "cpython" ruff >= 0.8.0 astor # code generation uv >= 0.2.24 diff --git a/test-requirements.txt b/test-requirements.txt index 4c56a29c7..b15592632 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -16,17 +16,17 @@ babel==2.17.0 # via sphinx black==25.11.0 ; implementation_name == 'cpython' # via -r test-requirements.in -certifi==2025.10.5 +certifi==2025.11.12 # via requests cffi==2.0.0 ; os_name == 'nt' or platform_python_implementation != 'PyPy' # via # -r test-requirements.in # cryptography -cfgv==3.4.0 +cfgv==3.5.0 # via pre-commit charset-normalizer==3.4.4 # via requests -click==8.3.0 ; implementation_name == 'cpython' +click==8.3.1 ; implementation_name == 'cpython' # via black codespell==2.4.1 # via -r test-requirements.in @@ -36,7 +36,7 @@ colorama==0.4.6 ; sys_platform == 'win32' # pylint # pytest # sphinx -coverage==7.11.3 +coverage==7.12.0 # via -r test-requirements.in cryptography==46.0.3 # via @@ -48,9 +48,11 @@ dill==0.4.0 # via pylint distlib==0.4.0 # via virtualenv -docutils==0.21.2 +docutils==0.21.2 ; python_full_version < '3.11' # via sphinx -exceptiongroup==1.3.0 ; python_full_version < '3.11' +docutils==0.22.3 ; python_full_version >= '3.11' + # via sphinx +exceptiongroup==1.3.1 ; python_full_version < '3.11' # via # -r test-requirements.in # pytest @@ -73,11 +75,13 @@ jedi==0.19.2 ; implementation_name == 'cpython' # via -r test-requirements.in jinja2==3.1.6 # via sphinx +librt==0.6.3 ; implementation_name == 'cpython' + # via mypy markupsafe==3.0.3 # via jinja2 mccabe==0.7.0 # via pylint -mypy==1.18.2 +mypy==1.19.0 ; implementation_name == 'cpython' # via -r test-requirements.in mypy-extensions==1.1.0 # via @@ -97,7 +101,7 @@ packaging==25.0 # sphinx parso==0.8.5 ; implementation_name == 'cpython' # via jedi -pathspec==0.12.1 +pathspec==0.12.1 ; implementation_name == 'cpython' # via # black # mypy @@ -108,7 +112,7 @@ platformdirs==4.5.0 # virtualenv pluggy==1.6.0 # via pytest -pre-commit==4.4.0 +pre-commit==4.5.0 # via -r test-requirements.in pycparser==2.23 ; (implementation_name != 'PyPy' and os_name == 'nt') or (implementation_name != 'PyPy' and platform_python_implementation != 'PyPy') # via cffi @@ -116,13 +120,13 @@ pygments==2.19.2 # via # pytest # sphinx -pylint==4.0.2 +pylint==4.0.4 # via -r test-requirements.in pyopenssl==25.3.0 # via -r test-requirements.in pyright==1.1.407 # via -r test-requirements.in -pytest==9.0.0 +pytest==9.0.1 # via -r test-requirements.in pytokens==0.3.0 ; implementation_name == 'cpython' # via black @@ -130,9 +134,9 @@ pyyaml==6.0.3 # via pre-commit requests==2.32.5 # via sphinx -roman-numerals-py==3.1.0 ; python_full_version >= '3.11' +roman-numerals==3.1.0 ; python_full_version >= '3.11' # via sphinx -ruff==0.14.6 +ruff==0.14.7 # via -r test-requirements.in sniffio==1.3.1 # via -r test-requirements.in @@ -142,7 +146,7 @@ sortedcontainers==2.4.0 # via -r test-requirements.in sphinx==8.1.3 ; python_full_version < '3.11' # via -r test-requirements.in -sphinx==8.2.3 ; python_full_version >= '3.11' +sphinx==9.0.1 ; python_full_version >= '3.11' # via -r test-requirements.in sphinxcontrib-applehelp==2.0.0 # via sphinx @@ -171,7 +175,7 @@ types-cffi==1.17.0.20250915 # via # -r test-requirements.in # types-pyopenssl -types-docutils==0.22.2.20251006 +types-docutils==0.22.3.20251115 # via -r test-requirements.in types-pyopenssl==24.1.0.20240722 # via -r test-requirements.in @@ -192,7 +196,7 @@ typing-extensions==4.15.0 # virtualenv urllib3==2.5.0 # via requests -uv==0.9.11 +uv==0.9.14 # via -r test-requirements.in virtualenv==20.35.4 # via pre-commit