Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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"]
Expand All @@ -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"]
Expand Down
1 change: 0 additions & 1 deletion doc/en/example/.ruff.toml

This file was deleted.

12 changes: 10 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ lint.ignore = [
"PLR0912", # Too many branches
"PLR0913", # Too many arguments in function definition
"PLR0915", # Too many statements
"PLR0917", # Too many positional arguments
"PLR2004", # Magic value used in comparison
"PLR2044", # Line with empty comment
"PLR5501", # Use `elif` instead of `else` then `if`
Expand All @@ -182,15 +183,22 @@ lint.ignore = [
"RUF012", # Mutable class attributes should be annotated with `typing.ClassVar`
"RUF061", # Use context-manager form of `pytest.raises()`
]
lint.per-file-ignores."doc/**/*.py" = [
"PLR0133", # Two constants compared in a comparison,
"RUF059", # Unpacked variable is never used
"S102", # Use of `exec` detected
"TRY002", # Create your own exception
]
lint.per-file-ignores."src/_pytest/_py/**/*.py" = [
"B",
"PYI",
]
lint.per-file-ignores."src/_pytest/_version.py" = [
"I001",
]
# 'Unnecessary membership test on empty collection', always voluntary in tests
lint.per-file-ignores."testing/**/*.py" = [ "RUF060" ]
lint.per-file-ignores."testing/**/*.py" = [
"RUF060", # 'Unnecessary membership test on empty collection', always voluntary in tests
]
# can't be disabled on a line-by-line basis in file
lint.per-file-ignores."testing/code/test_source.py" = [
"F841",
Expand Down
4 changes: 2 additions & 2 deletions src/_pytest/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions src/_pytest/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/_pytest/hookspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
8 changes: 4 additions & 4 deletions src/_pytest/mark/structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,10 +531,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: ...

Expand All @@ -548,7 +548,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 = ...,
Expand Down
2 changes: 1 addition & 1 deletion src/_pytest/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
18 changes: 9 additions & 9 deletions src/_pytest/reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/_pytest/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/_pytest/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,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
Expand Down
2 changes: 1 addition & 1 deletion testing/python/metafunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Loading