From ce716bbfe3919a806f24c59db6c4275d17283a6d Mon Sep 17 00:00:00 2001 From: Tom Kuson Date: Thu, 24 Jul 2025 17:39:21 +0100 Subject: [PATCH 1/5] Add pyright hook --- .pre-commit-config.yaml | 7 +++++++ pytest_asyncio/plugin.py | 1 + 2 files changed, 8 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d42f18d0..a464f29b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -78,6 +78,13 @@ repos: rev: v1.11.0 hooks: - id: zizmor +- repo: https://github.com/RobertCraigie/pyright-python + rev: v1.1.403 + hooks: + - id: pyright + exclude: ^(docs|tests)/.* + additional_dependencies: + - pytest ci: skip: - actionlint-docker diff --git a/pytest_asyncio/plugin.py b/pytest_asyncio/plugin.py index 9bfcfc64..5955bb0a 100644 --- a/pytest_asyncio/plugin.py +++ b/pytest_asyncio/plugin.py @@ -392,6 +392,7 @@ def _from_function(cls, function: Function, /) -> Function: Function item. """ assert function.get_closest_marker("asyncio") + assert function.parent is not None subclass_instance = cls.from_parent( function.parent, name=function.name, From 7fbad9d968862b19fe992773bcabd47c6a14a684 Mon Sep 17 00:00:00 2001 From: Tom Kuson Date: Thu, 24 Jul 2025 18:37:07 +0100 Subject: [PATCH 2/5] Add nodeenv --- .pre-commit-config.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a464f29b..03854829 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -85,6 +85,7 @@ repos: exclude: ^(docs|tests)/.* additional_dependencies: - pytest + - nodeenv ci: skip: - actionlint-docker From d2e5efc201fbf017aaf68c02d05ec894eae9f7c0 Mon Sep 17 00:00:00 2001 From: Tom Kuson Date: Wed, 30 Jul 2025 01:16:32 +0100 Subject: [PATCH 3/5] Revert adding pyright --- .pre-commit-config.yaml | 8 -------- pytest_asyncio/plugin.py | 1 - 2 files changed, 9 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 03854829..d42f18d0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -78,14 +78,6 @@ repos: rev: v1.11.0 hooks: - id: zizmor -- repo: https://github.com/RobertCraigie/pyright-python - rev: v1.1.403 - hooks: - - id: pyright - exclude: ^(docs|tests)/.* - additional_dependencies: - - pytest - - nodeenv ci: skip: - actionlint-docker diff --git a/pytest_asyncio/plugin.py b/pytest_asyncio/plugin.py index 5955bb0a..9bfcfc64 100644 --- a/pytest_asyncio/plugin.py +++ b/pytest_asyncio/plugin.py @@ -392,7 +392,6 @@ def _from_function(cls, function: Function, /) -> Function: Function item. """ assert function.get_closest_marker("asyncio") - assert function.parent is not None subclass_instance = cls.from_parent( function.parent, name=function.name, From 4dd53784f3981af55cea61de39d427cc956f93e8 Mon Sep 17 00:00:00 2001 From: Tom Kuson Date: Wed, 30 Jul 2025 01:41:03 +0100 Subject: [PATCH 4/5] Add pyright type-checking to tox configuration --- changelog.d/731.downstream.rst | 1 + pytest_asyncio/plugin.py | 1 + tox.ini | 9 ++++++++- 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 changelog.d/731.downstream.rst diff --git a/changelog.d/731.downstream.rst b/changelog.d/731.downstream.rst new file mode 100644 index 00000000..3b19d48e --- /dev/null +++ b/changelog.d/731.downstream.rst @@ -0,0 +1 @@ +Added pyright type-checking. diff --git a/pytest_asyncio/plugin.py b/pytest_asyncio/plugin.py index 9bfcfc64..5955bb0a 100644 --- a/pytest_asyncio/plugin.py +++ b/pytest_asyncio/plugin.py @@ -392,6 +392,7 @@ def _from_function(cls, function: Function, /) -> Function: Function item. """ assert function.get_closest_marker("asyncio") + assert function.parent is not None subclass_instance = cls.from_parent( function.parent, name=function.name, diff --git a/tox.ini b/tox.ini index e6457f56..74d102da 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] minversion = 4.9.0 -envlist = py39, py310, py311, py312, py313, py314, pytest-min, docs +envlist = py39, py310, py311, py312, py313, py314, pytest-min, docs, pyright isolated_build = true passenv = CI @@ -69,6 +69,13 @@ passenv = SSH_AUTH_SOCK skip_install = false +[testenv:pyright] +deps = + pyright[nodejs] + pytest +commands = pyright pytest_asyncio/ +skip_install = true + [gh-actions] python = 3.9: py39, pytest-min From 5ad6dabb0ed9dc42b1d213fe1648457fa515fbb7 Mon Sep 17 00:00:00 2001 From: Tom Kuson Date: Wed, 30 Jul 2025 01:52:05 +0100 Subject: [PATCH 5/5] Run pyright in GitHub Actions --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 74d102da..3608cc56 100644 --- a/tox.ini +++ b/tox.ini @@ -82,6 +82,6 @@ python = 3.10: py310 3.11: py311 3.12: py312 - 3.13: py313 + 3.13: py313, pyright 3.14-dev: py314 pypy3: pypy3