Skip to content

[pre-commit.ci] pre-commit autoupdate #13475

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 3, 2025
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
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.11.11"
rev: "v0.11.12"
hooks:
- id: ruff
args: ["--fix"]
Expand All @@ -12,7 +12,7 @@ repos:
- id: end-of-file-fixer
- id: check-yaml
- repo: https://github.com/woodruffw/zizmor-pre-commit
rev: v1.8.0
rev: v1.9.0
hooks:
- id: zizmor
- repo: https://github.com/adamchainz/blacken-docs
Expand All @@ -32,7 +32,7 @@ repos:
hooks:
- id: python-use-type-annotations
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.15.0
rev: v1.16.0
hooks:
- id: mypy
files: ^(src/|testing/|scripts/)
Expand Down
1 change: 0 additions & 1 deletion src/_pytest/assertion/rewrite.py
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,6 @@ def run(self, mod: ast.Module) -> None:
if doc is not None and self.is_rewrite_disabled(doc):
return
pos = 0
item = None
for item in mod.body:
if (
expect_docstring
Expand Down
10 changes: 5 additions & 5 deletions src/_pytest/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ def get_config(
args: list[str] | None = None,
plugins: Sequence[str | _PluggyPlugin] | None = None,
) -> Config:
# subsequent calls to main will create a fresh instance
# Subsequent calls to main will create a fresh instance.
pluginmanager = PytestPluginManager()
config = Config(
pluginmanager,
Expand Down Expand Up @@ -330,21 +330,21 @@ def _prepareconfig(
)
raise TypeError(msg.format(args, type(args)))

config = get_config(args, plugins)
pluginmanager = config.pluginmanager
initial_config = get_config(args, plugins)
pluginmanager = initial_config.pluginmanager
try:
if plugins:
for plugin in plugins:
if isinstance(plugin, str):
pluginmanager.consider_pluginarg(plugin)
else:
pluginmanager.register(plugin)
config = pluginmanager.hook.pytest_cmdline_parse(
config: Config = pluginmanager.hook.pytest_cmdline_parse(
pluginmanager=pluginmanager, args=args
)
return config
except BaseException:
config._ensure_unconfigure()
initial_config._ensure_unconfigure()
raise


Expand Down
11 changes: 6 additions & 5 deletions src/_pytest/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -1106,8 +1106,7 @@ def execute(self, request: SubRequest) -> FixtureValue:
exc, exc_tb = self.cached_result[2]
raise exc.with_traceback(exc_tb)
else:
result = self.cached_result[0]
return result
return self.cached_result[0]
# We have a previous but differently parametrized fixture instance
# so we need to tear it down before creating a new one.
self.finish(request)
Expand All @@ -1123,10 +1122,12 @@ def execute(self, request: SubRequest) -> FixtureValue:
ihook = request.node.ihook
try:
# Setup the fixture, run the code in it, and cache the value
# in self.cached_result
result = ihook.pytest_fixture_setup(fixturedef=self, request=request)
# in self.cached_result.
result: FixtureValue = ihook.pytest_fixture_setup(
fixturedef=self, request=request
)
finally:
# schedule our finalizer, even if the setup failed
# Schedule our finalizer, even if the setup failed.
request.node.addfinalizer(finalizer)

return result
Expand Down
3 changes: 1 addition & 2 deletions src/_pytest/python_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,8 +474,7 @@ def is_bool(val: Any) -> bool:
result: bool = abs(self.expected - actual) <= self.tolerance
return result

# Ignore type because of https://github.com/python/mypy/issues/4266.
__hash__ = None # type: ignore
__hash__ = None

@property
def tolerance(self):
Expand Down
6 changes: 4 additions & 2 deletions src/_pytest/recwarn.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def warns(
return func(*args[1:], **kwargs)


class WarningsRecorder(warnings.catch_warnings): # type:ignore[type-arg]
class WarningsRecorder(warnings.catch_warnings):
"""A context manager to record raised warnings.

Each recorded warning is an instance of :class:`warnings.WarningMessage`.
Expand Down Expand Up @@ -226,7 +226,9 @@ def clear(self) -> None:
"""Clear the list of recorded warnings."""
self._list[:] = []

def __enter__(self) -> Self:
# Type ignored because we basically want the `catch_warnings` generic type
# parameter to be ourselves but that is not possible(?).
def __enter__(self) -> Self: # type: ignore[override]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this is weird.

if self._entered:
__tracebackhide__ = True
raise RuntimeError(f"Cannot enter {self!r} twice")
Expand Down
2 changes: 1 addition & 1 deletion testing/test_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -1615,7 +1615,7 @@ def __init__(self, name, parent, x):
self.x = x

@classmethod
def from_parent(cls, parent, *, name, x):
def from_parent(cls, parent, *, name, x): # type: ignore[override]
return super().from_parent(parent=parent, name=name, x=x)

collector = MyCollector.from_parent(parent=request.session, name="foo", x=10)
Expand Down
18 changes: 11 additions & 7 deletions testing/test_junitxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ def nodeval(node: minidom.Element, name: str) -> str | None:


class DomDocument:
def __init__(self, dom: minidom.Document):
self._node = dom

_node: minidom.Document | minidom.Element

def __init__(self, dom: minidom.Document) -> None:
self._node = dom

def find_first_by_tag(self, tag: str) -> DomNode | None:
return self.find_nth_by_tag(tag, 0)

Expand All @@ -105,7 +105,9 @@ def find_by_tag(self, tag: str) -> list[DomNode]:

@property
def children(self) -> list[DomNode]:
return [DomNode(x) for x in self._node.childNodes]
return [
DomNode(x) for x in self._node.childNodes if isinstance(x, minidom.Element)
]

@property
def get_unique_child(self) -> DomNode:
Expand All @@ -120,7 +122,7 @@ def toxml(self) -> str:
class DomNode(DomDocument):
_node: minidom.Element

def __init__(self, dom: minidom.Element):
def __init__(self, dom: minidom.Element) -> None:
self._node = dom

def __repr__(self) -> str:
Expand All @@ -129,7 +131,7 @@ def __repr__(self) -> str:
def __getitem__(self, key: str) -> str:
node = self._node.getAttributeNode(key)
if node is not None:
return cast(str, node.value)
return node.value
else:
raise KeyError(key)

Expand All @@ -139,7 +141,9 @@ def assert_attr(self, **kwargs: object) -> None:

@property
def text(self) -> str:
return cast(str, self._node.childNodes[0].wholeText)
text = self._node.childNodes[0]
assert isinstance(text, minidom.Text)
return text.wholeText

@property
def tag(self) -> str:
Expand Down
Loading