From 0c88bc7740a574f6f883ec2124432b2cea189afa Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 15 Jul 2024 23:30:27 +0000 Subject: [PATCH 1/7] [pre-commit.ci] pre-commit autoupdate (#3034) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [pre-commit.ci] pre-commit autoupdate updates: - [github.com/astral-sh/ruff-pre-commit: v0.5.1 → v0.5.2](https://github.com/astral-sh/ruff-pre-commit/compare/v0.5.1...v0.5.2) * Use `is` instead of `==` for type comparison --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: CoolCat467 <52022020+CoolCat467@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- src/trio/_core/_tests/test_run.py | 2 +- src/trio/_socket.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5863ee89b9..5ecc01fee4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -23,7 +23,7 @@ repos: hooks: - id: black - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.5.1 + rev: v0.5.2 hooks: - id: ruff types: [file] diff --git a/src/trio/_core/_tests/test_run.py b/src/trio/_core/_tests/test_run.py index bab8b52a4a..ee823cb81a 100644 --- a/src/trio/_core/_tests/test_run.py +++ b/src/trio/_core/_tests/test_run.py @@ -2704,7 +2704,7 @@ async def start_raiser() -> None: else: # Check attributes, not identity, because should_be_raiser_exc may be a # copy of raiser_exc rather than raiser_exc by identity. - assert type(should_be_raiser_exc) == type(raiser_exc) + assert type(should_be_raiser_exc) is type(raiser_exc) assert should_be_raiser_exc.message == raiser_exc.message assert should_be_raiser_exc.exceptions == raiser_exc.exceptions diff --git a/src/trio/_socket.py b/src/trio/_socket.py index 80fb85f04e..0a3bd1cba1 100644 --- a/src/trio/_socket.py +++ b/src/trio/_socket.py @@ -528,7 +528,7 @@ def __init__(self) -> None: # make sure this __init__ works with multiple inheritance super().__init__() # and only raises error if it's directly constructed - if type(self) == SocketType: + if type(self) is SocketType: raise TypeError( "SocketType is an abstract class; use trio.socket.socket if you " "want to construct a socket object" From a3e8665296e66a84a9de1fba71a38f139088a627 Mon Sep 17 00:00:00 2001 From: CoolCat467 <52022020+CoolCat467@users.noreply.github.com> Date: Fri, 19 Jul 2024 23:18:50 -0500 Subject: [PATCH 2/7] Use `--universal` flag with uv pip compile (#3032) * Use `--universal` flag with uv pip compile * Upgrade to uv `0.2.26`, fixed https://github.com/astral-sh/uv/issues/4885 * Update uv and remove `--no-strip-markers` Apparently `--universal` implies `--no-strip-markers` --- .github/workflows/autodeps.yml | 4 ++-- check.sh | 4 ++-- docs-requirements.txt | 14 ++++++++++---- test-requirements.in | 2 +- test-requirements.txt | 22 +++++++++++++++------- 5 files changed, 30 insertions(+), 16 deletions(-) diff --git a/.github/workflows/autodeps.yml b/.github/workflows/autodeps.yml index 2466c89fdd..0e0655c5aa 100644 --- a/.github/workflows/autodeps.yml +++ b/.github/workflows/autodeps.yml @@ -28,8 +28,8 @@ jobs: run: | python -m pip install -U pip pre-commit python -m pip install -r test-requirements.txt - uv pip compile --no-strip-markers --python-version=3.8 --upgrade test-requirements.in -o test-requirements.txt - uv pip compile --no-strip-markers --python-version=3.8 --upgrade docs-requirements.in -o docs-requirements.txt + uv pip compile --universal --python-version=3.8 --upgrade test-requirements.in -o test-requirements.txt + uv pip compile --universal --python-version=3.8 --upgrade docs-requirements.in -o docs-requirements.txt pre-commit autoupdate --jobs 0 - name: Black run: | diff --git a/check.sh b/check.sh index 044a02962a..d6efb8749a 100755 --- a/check.sh +++ b/check.sh @@ -78,10 +78,10 @@ fi # Check pip compile is consistent echo "::group::Pip Compile - Tests" -uv pip compile --no-strip-markers --python-version=3.8 test-requirements.in -o test-requirements.txt +uv pip compile --universal --python-version=3.8 test-requirements.in -o test-requirements.txt echo "::endgroup::" echo "::group::Pip Compile - Docs" -uv pip compile --no-strip-markers --python-version=3.8 docs-requirements.in -o docs-requirements.txt +uv pip compile --universal --python-version=3.8 docs-requirements.in -o docs-requirements.txt echo "::endgroup::" if git status --porcelain | grep -q "requirements.txt"; then diff --git a/docs-requirements.txt b/docs-requirements.txt index b9def33ac2..461d6e3d93 100644 --- a/docs-requirements.txt +++ b/docs-requirements.txt @@ -1,5 +1,5 @@ # This file was autogenerated by uv via the following command: -# uv pip compile --no-strip-markers --python-version=3.8 docs-requirements.in -o docs-requirements.txt +# uv pip compile --universal --python-version=3.8 docs-requirements.in -o docs-requirements.txt alabaster==0.7.13 # via sphinx attrs==23.2.0 @@ -12,12 +12,18 @@ beautifulsoup4==4.12.3 # via sphinx-codeautolink certifi==2024.7.4 # via requests -cffi==1.16.0 ; platform_python_implementation != 'PyPy' - # via cryptography +cffi==1.16.0 ; os_name == 'nt' or platform_python_implementation != 'PyPy' + # via + # -r docs-requirements.in + # cryptography charset-normalizer==3.3.2 # via requests click==8.1.7 # via towncrier +colorama==0.4.6 ; platform_system == 'Windows' or sys_platform == 'win32' + # via + # click + # sphinx cryptography==42.0.8 # via pyopenssl docutils==0.20.1 @@ -51,7 +57,7 @@ outcome==1.3.0.post0 # via -r docs-requirements.in packaging==24.1 # via sphinx -pycparser==2.22 ; platform_python_implementation != 'PyPy' +pycparser==2.22 ; os_name == 'nt' or platform_python_implementation != 'PyPy' # via cffi pygments==2.18.0 # via sphinx diff --git a/test-requirements.in b/test-requirements.in index 95da5ea080..af8a751b13 100644 --- a/test-requirements.in +++ b/test-requirements.in @@ -15,7 +15,7 @@ mypy; implementation_name == "cpython" types-pyOpenSSL; implementation_name == "cpython" # and annotations ruff >= 0.4.3 astor # code generation -uv >= 0.2.22 +uv >= 0.2.24 codespell # https://github.com/python-trio/trio/pull/654#issuecomment-420518745 diff --git a/test-requirements.txt b/test-requirements.txt index 9474325a54..92289774a2 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,5 +1,5 @@ # This file was autogenerated by uv via the following command: -# uv pip compile --no-strip-markers --python-version=3.8 test-requirements.in -o test-requirements.txt +# uv pip compile --universal --python-version=3.8 test-requirements.in -o test-requirements.txt alabaster==0.7.13 # via sphinx astor==0.8.1 @@ -18,14 +18,22 @@ black==24.4.2 ; implementation_name == 'cpython' # via -r test-requirements.in certifi==2024.7.4 # via requests -cffi==1.17.0rc1 ; platform_python_implementation != 'PyPy' - # via cryptography +cffi==1.17.0rc1 ; os_name == 'nt' or platform_python_implementation != 'PyPy' + # via + # -r test-requirements.in + # cryptography charset-normalizer==3.3.2 # via requests click==8.1.7 ; implementation_name == 'cpython' # via black codespell==2.3.0 # via -r test-requirements.in +colorama==0.4.6 ; sys_platform == 'win32' or (implementation_name == 'cpython' and platform_system == 'Windows') + # via + # click + # pylint + # pytest + # sphinx coverage==7.5.4 # via -r test-requirements.in cryptography==42.0.8 @@ -34,7 +42,7 @@ cryptography==42.0.8 # pyopenssl # trustme # types-pyopenssl -dill==0.3.8 ; python_version < '3.11' +dill==0.3.8 # via pylint docutils==0.20.1 # via sphinx @@ -89,7 +97,7 @@ platformdirs==4.2.2 # pylint pluggy==1.5.0 # via pytest -pycparser==2.22 ; platform_python_implementation != 'PyPy' +pycparser==2.22 ; os_name == 'nt' or platform_python_implementation != 'PyPy' # via cffi pygments==2.18.0 # via sphinx @@ -127,7 +135,7 @@ sphinxcontrib-qthelp==1.0.3 # via sphinx sphinxcontrib-serializinghtml==1.1.5 # via sphinx -tomli==2.0.1 ; python_version < '3.11' or (python_version < '3.11' and implementation_name == 'cpython') +tomli==2.0.1 ; python_version < '3.11' # via # black # mypy @@ -156,7 +164,7 @@ typing-extensions==4.12.2 # pylint urllib3==2.2.2 # via requests -uv==0.2.22 +uv==0.2.26 # via -r test-requirements.in zipp==3.19.2 ; python_version < '3.10' # via importlib-metadata From c06f9e963822812dfe7cecf8fcc4dcf01d34c035 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 23 Jul 2024 08:59:29 +0900 Subject: [PATCH 3/7] [pre-commit.ci] pre-commit autoupdate (#3037) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5ecc01fee4..41f0232186 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -23,7 +23,7 @@ repos: hooks: - id: black - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.5.2 + rev: v0.5.4 hooks: - id: ruff types: [file] From 63ec8865701ebec606dbbb8f8f1a4580baa39410 Mon Sep 17 00:00:00 2001 From: CoolCat467 <52022020+CoolCat467@users.noreply.github.com> Date: Tue, 23 Jul 2024 00:48:53 -0500 Subject: [PATCH 4/7] Update to mypy 1.11.0 --- test-requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test-requirements.txt b/test-requirements.txt index 92289774a2..3dec7a570b 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -71,7 +71,7 @@ markupsafe==2.1.5 # via jinja2 mccabe==0.7.0 # via pylint -mypy==1.10.1 ; implementation_name == 'cpython' +mypy==1.11.0 ; implementation_name == 'cpython' # via -r test-requirements.in mypy-extensions==1.0.0 ; implementation_name == 'cpython' # via From 69819e37d0f02f41a38461cb338b96127caa2909 Mon Sep 17 00:00:00 2001 From: CoolCat467 <52022020+CoolCat467@users.noreply.github.com> Date: Tue, 23 Jul 2024 00:55:23 -0500 Subject: [PATCH 5/7] Assert that coroutine frame exists --- src/trio/_core/_ki.py | 1 + src/trio/_core/_run.py | 1 + 2 files changed, 2 insertions(+) diff --git a/src/trio/_core/_ki.py b/src/trio/_core/_ki.py index 7d07caada2..a8431f89db 100644 --- a/src/trio/_core/_ki.py +++ b/src/trio/_core/_ki.py @@ -143,6 +143,7 @@ def decorator(fn: Callable[ArgsT, RetT]) -> Callable[ArgsT, RetT]: def wrapper(*args: ArgsT.args, **kwargs: ArgsT.kwargs) -> RetT: # type: ignore[misc] # See the comment for regular generators below coro = fn(*args, **kwargs) + assert coro.cr_frame is not None, "Coroutine frame should exist" coro.cr_frame.f_locals[LOCALS_KEY_KI_PROTECTION_ENABLED] = enabled return coro # type: ignore[return-value] diff --git a/src/trio/_core/_run.py b/src/trio/_core/_run.py index c6faabaf72..5453c3602e 100644 --- a/src/trio/_core/_run.py +++ b/src/trio/_core/_run.py @@ -1782,6 +1782,7 @@ async def python_wrapper(orig_coro: Awaitable[RetT]) -> RetT: return await orig_coro coro = python_wrapper(coro) + assert coro.cr_frame is not None, "Coroutine frame should exist" coro.cr_frame.f_locals.setdefault(LOCALS_KEY_KI_PROTECTION_ENABLED, system_task) ###### From 58615213e9e1fb3768ba77e409de63bfbd73c9e9 Mon Sep 17 00:00:00 2001 From: CoolCat467 <52022020+CoolCat467@users.noreply.github.com> Date: Tue, 23 Jul 2024 00:55:38 -0500 Subject: [PATCH 6/7] Remove now unused type ignores --- src/trio/_tests/test_util.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/trio/_tests/test_util.py b/src/trio/_tests/test_util.py index e5422770cb..3e62eb622e 100644 --- a/src/trio/_tests/test_util.py +++ b/src/trio/_tests/test_util.py @@ -269,7 +269,7 @@ def test_fixup_module_metadata() -> None: assert mod.SomeClass.method.__module__ == "trio.somemodule" # type: ignore[attr-defined] assert mod.SomeClass.method.__qualname__ == "SomeClass.method" # type: ignore[attr-defined] # Make coverage happy. - non_trio_module.some_func() # type: ignore[no-untyped-call] - mod.some_func() # type: ignore[no-untyped-call] - mod._private() # type: ignore[no-untyped-call] + non_trio_module.some_func() + mod.some_func() + mod._private() mod.SomeClass().method() From 20f92914da0a28a6e0ac6eb17dd7fa56c6602cc0 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 29 Jul 2024 23:03:49 +0000 Subject: [PATCH 7/7] =?UTF-8?q?[pre-commit.ci]=20pre-commit=20autoupdate?= =?UTF-8?q?=20ruff-pre-commit:=20v0.5.4=20=E2=86=92=20v0.5.5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.5.4 → v0.5.5](https://github.com/astral-sh/ruff-pre-commit/compare/v0.5.4...v0.5.5) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 41f0232186..810c28e4a2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -23,7 +23,7 @@ repos: hooks: - id: black - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.5.4 + rev: v0.5.5 hooks: - id: ruff types: [file]