diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6f721cb58..38f8b73c9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,7 +22,7 @@ repos: hooks: - id: black - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.7.4 + rev: v0.8.0 hooks: - id: ruff types: [file] diff --git a/pyproject.toml b/pyproject.toml index cde205b81..a9785c0be 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -125,15 +125,13 @@ select = [ "Q", # flake8-quotes "RUF", # Ruff-specific rules "SIM", # flake8-simplify - "TCH", # flake8-type-checking + "TC", # flake8-type-checking "UP", # pyupgrade "W", # Warning "YTT", # flake8-2020 ] extend-ignore = [ 'A002', # builtin-argument-shadowing - 'ANN101', # missing-type-self - 'ANN102', # missing-type-cls 'ANN401', # any-type (mypy's `disallow_any_explicit` is better) 'E402', # module-import-not-at-top-of-file (usually OS-specific) 'E501', # line-too-long diff --git a/src/trio/_dtls.py b/src/trio/_dtls.py index c971471c0..7f4bccc9e 100644 --- a/src/trio/_dtls.py +++ b/src/trio/_dtls.py @@ -36,7 +36,7 @@ from types import TracebackType # See DTLSEndpoint.__init__ for why this is imported here - from OpenSSL import SSL # noqa: TCH004 + from OpenSSL import SSL # noqa: TC004 from typing_extensions import Self, TypeAlias, TypeVarTuple, Unpack from trio._socket import AddressFormat diff --git a/src/trio/_socket.py b/src/trio/_socket.py index ce57aab9c..259992b71 100644 --- a/src/trio/_socket.py +++ b/src/trio/_socket.py @@ -12,7 +12,6 @@ from typing import ( TYPE_CHECKING, Any, - Literal, SupportsIndex, TypeVar, Union, @@ -337,7 +336,7 @@ def fromshare(info: bytes) -> SocketType: TypeT: TypeAlias = int FamilyDefault = _stdlib_socket.AF_INET else: - FamilyDefault: Literal[None] = None + FamilyDefault: None = None FamilyT: TypeAlias = Union[int, AddressFamily, None] TypeT: TypeAlias = Union[_stdlib_socket.socket, int] diff --git a/src/trio/_subprocess_platform/__init__.py b/src/trio/_subprocess_platform/__init__.py index 9a5e4d1da..daa28d8cd 100644 --- a/src/trio/_subprocess_platform/__init__.py +++ b/src/trio/_subprocess_platform/__init__.py @@ -8,7 +8,7 @@ import trio from .. import _core, _subprocess -from .._abc import ReceiveStream, SendStream # noqa: TCH001 +from .._abc import ReceiveStream, SendStream # noqa: TC001 _wait_child_exiting_error: ImportError | None = None _create_child_pipe_error: ImportError | None = None diff --git a/src/trio/_tests/test_testing_raisesgroup.py b/src/trio/_tests/test_testing_raisesgroup.py index 7b2fe4417..9ab84cd3b 100644 --- a/src/trio/_tests/test_testing_raisesgroup.py +++ b/src/trio/_tests/test_testing_raisesgroup.py @@ -353,9 +353,9 @@ def check_errno_is_5(e: OSError) -> bool: def test_matcher_tostring() -> None: assert str(Matcher(ValueError)) == "Matcher(ValueError)" assert str(Matcher(match="[a-z]")) == "Matcher(match='[a-z]')" - pattern_no_flags = re.compile("noflag", 0) + pattern_no_flags = re.compile(r"noflag", 0) assert str(Matcher(match=pattern_no_flags)) == "Matcher(match='noflag')" - pattern_flags = re.compile("noflag", re.IGNORECASE) + pattern_flags = re.compile(r"noflag", re.IGNORECASE) assert str(Matcher(match=pattern_flags)) == f"Matcher(match={pattern_flags!r})" assert ( str(Matcher(ValueError, match="re", check=bool)) diff --git a/src/trio/_tests/test_threads.py b/src/trio/_tests/test_threads.py index 641454d2e..75f9142d6 100644 --- a/src/trio/_tests/test_threads.py +++ b/src/trio/_tests/test_threads.py @@ -220,7 +220,7 @@ def f(name: str) -> Callable[[None], threading.Thread]: # test that you can set a custom name, and that it's reset afterwards async def test_thread_name(name: str) -> None: thread = await to_thread_run_sync(f(name), thread_name=name) - assert re.match("Trio thread [0-9]*", thread.name) + assert re.match(r"Trio thread [0-9]*", thread.name) await test_thread_name("") await test_thread_name("fobiedoo") @@ -301,7 +301,7 @@ async def test_thread_name(name: str, expected: str | None = None) -> None: os_thread_name = _get_thread_name(thread.ident) assert os_thread_name is not None, "should skip earlier if this is the case" - assert re.match("Trio thread [0-9]*", os_thread_name) + assert re.match(r"Trio thread [0-9]*", os_thread_name) await test_thread_name("") await test_thread_name("fobiedoo") diff --git a/src/trio/testing/_raises_group.py b/src/trio/testing/_raises_group.py index 717b5f938..3bb52b4e8 100644 --- a/src/trio/testing/_raises_group.py +++ b/src/trio/testing/_raises_group.py @@ -147,7 +147,7 @@ def _stringify_exception(exc: BaseException) -> str: # String patterns default to including the unicode flag. -_regex_no_flags = re.compile("").flags +_regex_no_flags = re.compile(r"").flags @final diff --git a/test-requirements.in b/test-requirements.in index 1c30d8982..809e171e3 100644 --- a/test-requirements.in +++ b/test-requirements.in @@ -13,7 +13,7 @@ cryptography>=41.0.0 # cryptography<41 segfaults on pypy3.10 black; implementation_name == "cpython" mypy # Would use mypy[faster-cache], but orjson has build issues on pypy orjson; implementation_name == "cpython" -ruff >= 0.6.6 +ruff >= 0.8.0 astor # code generation uv >= 0.2.24 codespell diff --git a/test-requirements.txt b/test-requirements.txt index 158e04a53..efe920af0 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -113,7 +113,7 @@ pytest==8.3.3 # via -r test-requirements.in requests==2.32.3 # via sphinx -ruff==0.7.3 +ruff==0.8.0 # via -r test-requirements.in sniffio==1.3.1 # via -r test-requirements.in