From b87e4205aca5268ac7612b3d09f56ef58b3e67ac Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 27 Jul 2026 21:10:17 +0000 Subject: [PATCH 1/2] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.15.22 → v0.16.0](https://github.com/astral-sh/ruff-pre-commit/compare/v0.15.22...v0.16.0) - [github.com/woodruffw/zizmor-pre-commit: v1.27.0 → v1.28.0](https://github.com/woodruffw/zizmor-pre-commit/compare/v1.27.0...v1.28.0) --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1f3e8f3bd53..1b40df3f0cd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,7 @@ minimum_pre_commit_version: "4.4.0" repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.15.22" + rev: "v0.16.0" hooks: - id: ruff-check args: ["--fix"] @@ -13,7 +13,7 @@ repos: - id: end-of-file-fixer - id: check-yaml - repo: https://github.com/woodruffw/zizmor-pre-commit - rev: v1.27.0 + rev: v1.28.0 hooks: - id: zizmor args: ["--fix", "--no-progress"] From 922dd6c9c5a1e31c54b5cc4efc9dd18a2ed165ac Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 27 Jul 2026 21:11:03 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .../global_testmodule_config/conftest.py | 1 - .../test_hello_world.py | 1 - doc/en/example/assertion/test_failures.py | 1 - doc/en/example/conftest.py | 1 - doc/en/example/multipython.py | 1 - doc/en/example/xfail_demo.py | 1 - src/_pytest/config/__init__.py | 4 ++-- src/_pytest/fixtures.py | 8 ++++---- src/_pytest/hookspec.py | 2 +- src/_pytest/mark/structures.py | 8 ++++---- src/_pytest/python.py | 2 +- src/_pytest/reports.py | 18 +++++++++--------- src/_pytest/runner.py | 2 +- src/_pytest/terminal.py | 2 +- testing/python/metafunc.py | 2 +- 15 files changed, 24 insertions(+), 30 deletions(-) diff --git a/doc/en/example/assertion/global_testmodule_config/conftest.py b/doc/en/example/assertion/global_testmodule_config/conftest.py index 835726473ba..76731e1a4b2 100644 --- a/doc/en/example/assertion/global_testmodule_config/conftest.py +++ b/doc/en/example/assertion/global_testmodule_config/conftest.py @@ -4,7 +4,6 @@ import pytest - mydir = os.path.dirname(__file__) diff --git a/doc/en/example/assertion/global_testmodule_config/test_hello_world.py b/doc/en/example/assertion/global_testmodule_config/test_hello_world.py index e3c927316f9..824b12277b9 100644 --- a/doc/en/example/assertion/global_testmodule_config/test_hello_world.py +++ b/doc/en/example/assertion/global_testmodule_config/test_hello_world.py @@ -1,6 +1,5 @@ from __future__ import annotations - hello = "world" diff --git a/doc/en/example/assertion/test_failures.py b/doc/en/example/assertion/test_failures.py index 17373f62213..7102dab31b3 100644 --- a/doc/en/example/assertion/test_failures.py +++ b/doc/en/example/assertion/test_failures.py @@ -3,7 +3,6 @@ import os.path import shutil - failure_demo = os.path.join(os.path.dirname(__file__), "failure_demo.py") pytest_plugins = ("pytester",) diff --git a/doc/en/example/conftest.py b/doc/en/example/conftest.py index 21c9a489961..8920201f354 100644 --- a/doc/en/example/conftest.py +++ b/doc/en/example/conftest.py @@ -1,4 +1,3 @@ from __future__ import annotations - collect_ignore = ["nonpython", "customdirectory"] diff --git a/doc/en/example/multipython.py b/doc/en/example/multipython.py index c04a2868812..3e9c0d43f0e 100644 --- a/doc/en/example/multipython.py +++ b/doc/en/example/multipython.py @@ -9,7 +9,6 @@ import pytest - pythonlist = ["python3.11", "python3.12", "python3.13"] diff --git a/doc/en/example/xfail_demo.py b/doc/en/example/xfail_demo.py index 4999e15f238..a064c4bcec4 100644 --- a/doc/en/example/xfail_demo.py +++ b/doc/en/example/xfail_demo.py @@ -2,7 +2,6 @@ import pytest - xfail = pytest.mark.xfail diff --git a/src/_pytest/config/__init__.py b/src/_pytest/config/__init__.py index 688cc8a9054..88ef033e202 100644 --- a/src/_pytest/config/__init__.py +++ b/src/_pytest/config/__init__.py @@ -881,7 +881,7 @@ def consider_module(self, mod: types.ModuleType) -> None: self._import_plugin_specs(getattr(mod, "pytest_plugins", [])) def _import_plugin_specs( - self, spec: None | types.ModuleType | str | Sequence[str] + self, spec: types.ModuleType | str | Sequence[str] | None ) -> None: plugins = _get_plugin_specs_as_list(spec) for import_spec in plugins: @@ -931,7 +931,7 @@ def import_plugin(self, modname: str, consider_entry_points: bool = False) -> No def _get_plugin_specs_as_list( - specs: None | types.ModuleType | str | Sequence[str], + specs: types.ModuleType | str | Sequence[str] | None, ) -> list[str]: """Parse a plugins specification into a list of plugin names.""" # None means empty. diff --git a/src/_pytest/fixtures.py b/src/_pytest/fixtures.py index 1b1591d1f83..44c304905e7 100644 --- a/src/_pytest/fixtures.py +++ b/src/_pytest/fixtures.py @@ -1118,7 +1118,7 @@ class FixtureDef(Generic[FixtureValue]): def __init__( self, config: Config, - baseid: str | None | NotSetType, + baseid: str | NotSetType | None, argname: str, func: _FixtureFunc[FixtureValue], scope: Scope | ScopeName | Callable[[str, Config], ScopeName] | None, @@ -2049,7 +2049,7 @@ def _register_fixture( *, name: str, func: _FixtureFunc[object], - nodeid: str | None | NotSetType = NOTSET, + nodeid: str | NotSetType | None = NOTSET, scope: Scope | ScopeName | Callable[[str, Config], ScopeName] = "function", params: Sequence[object] | None = None, ids: tuple[object | None, ...] | Callable[[Any], object | None] | None = None, @@ -2247,7 +2247,7 @@ def parsefactories( def parsefactories( self, node_or_obj: nodes.Node | object | NotSetType = NOTSET, - nodeid: str | None | NotSetType = NOTSET, + nodeid: str | NotSetType | None = NOTSET, *, holder: object | NotSetType = NOTSET, node: nodes.Node | NotSetType = NOTSET, @@ -2267,7 +2267,7 @@ def parsefactories( # Translate legacy API to holder/node sources of truth # Either effective_node or effective_nodeid will be set, not both effective_node: nodes.Node | NotSetType = NOTSET - effective_nodeid: str | None | NotSetType = NOTSET + effective_nodeid: str | NotSetType | None = NOTSET if holder is not NOTSET: # New API: holder and node explicitly provided diff --git a/src/_pytest/hookspec.py b/src/_pytest/hookspec.py index ba7ac2b76e3..350b333144a 100644 --- a/src/_pytest/hookspec.py +++ b/src/_pytest/hookspec.py @@ -508,7 +508,7 @@ def pytest_pycollect_makemodule(module_path: Path, parent) -> Module | None: @hookspec(firstresult=True) def pytest_pycollect_makeitem( collector: Module | Class, name: str, obj: object -) -> None | Item | Collector | list[Item | Collector]: +) -> Item | Collector | list[Item | Collector] | None: """Return a custom item/collector for a Python object in a module, or None. Stops at first non-None result, see :ref:`firstresult`. diff --git a/src/_pytest/mark/structures.py b/src/_pytest/mark/structures.py index 5449b17a1c6..751aa766c53 100644 --- a/src/_pytest/mark/structures.py +++ b/src/_pytest/mark/structures.py @@ -528,10 +528,10 @@ def __call__( *conditions: str | bool, reason: str = ..., run: bool = ..., - raises: None - | type[BaseException] + raises: type[BaseException] | tuple[type[BaseException], ...] - | AbstractRaises[BaseException] = ..., + | AbstractRaises[BaseException] + | None = ..., strict: bool = ..., ) -> MarkDecorator: ... @@ -545,7 +545,7 @@ def __call__( # type: ignore[override] # argvalues: Collection[ParameterSet | Sequence[object] | object], *, indirect: bool | Sequence[str] = ..., - ids: Iterable[None | str | float | int | bool | _HiddenParam] + ids: Iterable[str | float | int | bool | _HiddenParam | None] | Callable[[Any], object | None] | None = ..., scope: ScopeName | None = ..., diff --git a/src/_pytest/python.py b/src/_pytest/python.py index 4f168012c36..03bf8327c6c 100644 --- a/src/_pytest/python.py +++ b/src/_pytest/python.py @@ -238,7 +238,7 @@ def pytest_pycollect_makemodule(module_path: Path, parent) -> Module: @hookimpl(trylast=True) def pytest_pycollect_makeitem( collector: Module | Class, name: str, obj: object -) -> None | nodes.Item | nodes.Collector | list[nodes.Item | nodes.Collector]: +) -> nodes.Item | nodes.Collector | list[nodes.Item | nodes.Collector] | None: assert isinstance(collector, Class | Module), type(collector) # Nothing was collected elsewhere, let's do it here. if safe_isclass(obj): diff --git a/src/_pytest/reports.py b/src/_pytest/reports.py index 011a69db001..72fe10e96c7 100644 --- a/src/_pytest/reports.py +++ b/src/_pytest/reports.py @@ -62,7 +62,7 @@ class BaseReport: when: str | None location: tuple[str, int | None, str] | None longrepr: ( - None | ExceptionInfo[BaseException] | tuple[str, int, str] | str | TerminalRepr + ExceptionInfo[BaseException] | tuple[str, int, str] | str | TerminalRepr | None ) sections: list[tuple[str, str]] nodeid: str @@ -321,11 +321,11 @@ def __init__( location: tuple[str, int | None, str], keywords: Mapping[str, Any], outcome: Literal["passed", "failed", "skipped"], - longrepr: None - | ExceptionInfo[BaseException] + longrepr: ExceptionInfo[BaseException] | tuple[str, int, str] | str - | TerminalRepr, + | TerminalRepr + | None, when: Literal["setup", "call", "teardown"], sections: Iterable[tuple[str, str]] = (), duration: float = 0, @@ -399,11 +399,11 @@ def from_item_and_call(cls, item: Item, call: CallInfo[None]) -> TestReport: if not call.excinfo: outcome: Literal["passed", "failed", "skipped"] = "passed" longrepr: ( - None - | ExceptionInfo[BaseException] + ExceptionInfo[BaseException] | tuple[str, int, str] | str | TerminalRepr + | None ) = None else: if not isinstance(excinfo, ExceptionInfo): @@ -466,11 +466,11 @@ def __init__( self, nodeid: str, outcome: Literal["passed", "failed", "skipped"], - longrepr: None - | ExceptionInfo[BaseException] + longrepr: ExceptionInfo[BaseException] | tuple[str, int, str] | str - | TerminalRepr, + | TerminalRepr + | None, result: list[Item | Collector] | None, sections: Iterable[tuple[str, str]] = (), **extra, diff --git a/src/_pytest/runner.py b/src/_pytest/runner.py index 3f03cfaff77..cb723d134b9 100644 --- a/src/_pytest/runner.py +++ b/src/_pytest/runner.py @@ -408,7 +408,7 @@ def collect() -> list[Item | Collector]: call = CallInfo.from_call( collect, "collect", reraise=(KeyboardInterrupt, SystemExit) ) - longrepr: None | tuple[str, int, str] | str | TerminalRepr = None + longrepr: tuple[str, int, str] | str | TerminalRepr | None = None if not call.excinfo: outcome: Literal["passed", "skipped", "failed"] = "passed" else: diff --git a/src/_pytest/terminal.py b/src/_pytest/terminal.py index e46f8fb4c20..d07723de0d7 100644 --- a/src/_pytest/terminal.py +++ b/src/_pytest/terminal.py @@ -393,7 +393,7 @@ def __init__(self, config: Config, file: TextIO | None = None) -> None: file = sys.stdout self._tw = _pytest.config.create_terminal_writer(config, file) self._screen_width = self._tw.fullwidth - self.currentfspath: None | Path | str | int = None + self.currentfspath: Path | str | int | None = None self.reportchars = getreportopt(config) self.foldskipped = config.option.fold_skipped self.hasmarkup = self._tw.hasmarkup diff --git a/testing/python/metafunc.py b/testing/python/metafunc.py index 3dd07a0ffc8..1fb8f86c5b1 100644 --- a/testing/python/metafunc.py +++ b/testing/python/metafunc.py @@ -175,7 +175,7 @@ class Exc(Exception): def __repr__(self): return "Exc(from_gen)" - def gen() -> Iterator[int | None | Exc]: + def gen() -> Iterator[int | Exc | None]: yield 0 yield None yield Exc()