Skip to content

Commit 01de0c1

Browse files
[pre-commit.ci] pre-commit autoupdate (#13475)
* [pre-commit.ci] pre-commit autoupdate updates: - [github.com/astral-sh/ruff-pre-commit: v0.11.11 → v0.11.12](astral-sh/ruff-pre-commit@v0.11.11...v0.11.12) - [github.com/woodruffw/zizmor-pre-commit: v1.8.0 → v1.9.0](zizmorcore/zizmor-pre-commit@v1.8.0...v1.9.0) - [github.com/pre-commit/mirrors-mypy: v1.15.0 → v1.16.0](pre-commit/mirrors-mypy@v1.15.0...v1.16.0) * Fix new mypy errors --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Ran Benita <[email protected]>
1 parent c99e436 commit 01de0c1

File tree

8 files changed

+31
-26
lines changed

8 files changed

+31
-26
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
rev: "v0.11.11"
3+
rev: "v0.11.12"
44
hooks:
55
- id: ruff
66
args: ["--fix"]
@@ -12,7 +12,7 @@ repos:
1212
- id: end-of-file-fixer
1313
- id: check-yaml
1414
- repo: https://github.com/woodruffw/zizmor-pre-commit
15-
rev: v1.8.0
15+
rev: v1.9.0
1616
hooks:
1717
- id: zizmor
1818
- repo: https://github.com/adamchainz/blacken-docs
@@ -32,7 +32,7 @@ repos:
3232
hooks:
3333
- id: python-use-type-annotations
3434
- repo: https://github.com/pre-commit/mirrors-mypy
35-
rev: v1.15.0
35+
rev: v1.16.0
3636
hooks:
3737
- id: mypy
3838
files: ^(src/|testing/|scripts/)

src/_pytest/assertion/rewrite.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,6 @@ def run(self, mod: ast.Module) -> None:
702702
if doc is not None and self.is_rewrite_disabled(doc):
703703
return
704704
pos = 0
705-
item = None
706705
for item in mod.body:
707706
if (
708707
expect_docstring

src/_pytest/config/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ def get_config(
284284
args: list[str] | None = None,
285285
plugins: Sequence[str | _PluggyPlugin] | None = None,
286286
) -> Config:
287-
# subsequent calls to main will create a fresh instance
287+
# Subsequent calls to main will create a fresh instance.
288288
pluginmanager = PytestPluginManager()
289289
config = Config(
290290
pluginmanager,
@@ -330,21 +330,21 @@ def _prepareconfig(
330330
)
331331
raise TypeError(msg.format(args, type(args)))
332332

333-
config = get_config(args, plugins)
334-
pluginmanager = config.pluginmanager
333+
initial_config = get_config(args, plugins)
334+
pluginmanager = initial_config.pluginmanager
335335
try:
336336
if plugins:
337337
for plugin in plugins:
338338
if isinstance(plugin, str):
339339
pluginmanager.consider_pluginarg(plugin)
340340
else:
341341
pluginmanager.register(plugin)
342-
config = pluginmanager.hook.pytest_cmdline_parse(
342+
config: Config = pluginmanager.hook.pytest_cmdline_parse(
343343
pluginmanager=pluginmanager, args=args
344344
)
345345
return config
346346
except BaseException:
347-
config._ensure_unconfigure()
347+
initial_config._ensure_unconfigure()
348348
raise
349349

350350

src/_pytest/fixtures.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,8 +1106,7 @@ def execute(self, request: SubRequest) -> FixtureValue:
11061106
exc, exc_tb = self.cached_result[2]
11071107
raise exc.with_traceback(exc_tb)
11081108
else:
1109-
result = self.cached_result[0]
1110-
return result
1109+
return self.cached_result[0]
11111110
# We have a previous but differently parametrized fixture instance
11121111
# so we need to tear it down before creating a new one.
11131112
self.finish(request)
@@ -1123,10 +1122,12 @@ def execute(self, request: SubRequest) -> FixtureValue:
11231122
ihook = request.node.ihook
11241123
try:
11251124
# Setup the fixture, run the code in it, and cache the value
1126-
# in self.cached_result
1127-
result = ihook.pytest_fixture_setup(fixturedef=self, request=request)
1125+
# in self.cached_result.
1126+
result: FixtureValue = ihook.pytest_fixture_setup(
1127+
fixturedef=self, request=request
1128+
)
11281129
finally:
1129-
# schedule our finalizer, even if the setup failed
1130+
# Schedule our finalizer, even if the setup failed.
11301131
request.node.addfinalizer(finalizer)
11311132

11321133
return result

src/_pytest/python_api.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,8 +474,7 @@ def is_bool(val: Any) -> bool:
474474
result: bool = abs(self.expected - actual) <= self.tolerance
475475
return result
476476

477-
# Ignore type because of https://github.com/python/mypy/issues/4266.
478-
__hash__ = None # type: ignore
477+
__hash__ = None
479478

480479
@property
481480
def tolerance(self):

src/_pytest/recwarn.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ def warns(
167167
return func(*args[1:], **kwargs)
168168

169169

170-
class WarningsRecorder(warnings.catch_warnings): # type:ignore[type-arg]
170+
class WarningsRecorder(warnings.catch_warnings):
171171
"""A context manager to record raised warnings.
172172
173173
Each recorded warning is an instance of :class:`warnings.WarningMessage`.
@@ -226,7 +226,9 @@ def clear(self) -> None:
226226
"""Clear the list of recorded warnings."""
227227
self._list[:] = []
228228

229-
def __enter__(self) -> Self:
229+
# Type ignored because we basically want the `catch_warnings` generic type
230+
# parameter to be ourselves but that is not possible(?).
231+
def __enter__(self) -> Self: # type: ignore[override]
230232
if self._entered:
231233
__tracebackhide__ = True
232234
raise RuntimeError(f"Cannot enter {self!r} twice")

testing/test_collection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1615,7 +1615,7 @@ def __init__(self, name, parent, x):
16151615
self.x = x
16161616

16171617
@classmethod
1618-
def from_parent(cls, parent, *, name, x):
1618+
def from_parent(cls, parent, *, name, x): # type: ignore[override]
16191619
return super().from_parent(parent=parent, name=name, x=x)
16201620

16211621
collector = MyCollector.from_parent(parent=request.session, name="foo", x=10)

testing/test_junitxml.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,11 @@ def nodeval(node: minidom.Element, name: str) -> str | None:
7676

7777

7878
class DomDocument:
79-
def __init__(self, dom: minidom.Document):
80-
self._node = dom
81-
8279
_node: minidom.Document | minidom.Element
8380

81+
def __init__(self, dom: minidom.Document) -> None:
82+
self._node = dom
83+
8484
def find_first_by_tag(self, tag: str) -> DomNode | None:
8585
return self.find_nth_by_tag(tag, 0)
8686

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

106106
@property
107107
def children(self) -> list[DomNode]:
108-
return [DomNode(x) for x in self._node.childNodes]
108+
return [
109+
DomNode(x) for x in self._node.childNodes if isinstance(x, minidom.Element)
110+
]
109111

110112
@property
111113
def get_unique_child(self) -> DomNode:
@@ -120,7 +122,7 @@ def toxml(self) -> str:
120122
class DomNode(DomDocument):
121123
_node: minidom.Element
122124

123-
def __init__(self, dom: minidom.Element):
125+
def __init__(self, dom: minidom.Element) -> None:
124126
self._node = dom
125127

126128
def __repr__(self) -> str:
@@ -129,7 +131,7 @@ def __repr__(self) -> str:
129131
def __getitem__(self, key: str) -> str:
130132
node = self._node.getAttributeNode(key)
131133
if node is not None:
132-
return cast(str, node.value)
134+
return node.value
133135
else:
134136
raise KeyError(key)
135137

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

140142
@property
141143
def text(self) -> str:
142-
return cast(str, self._node.childNodes[0].wholeText)
144+
text = self._node.childNodes[0]
145+
assert isinstance(text, minidom.Text)
146+
return text.wholeText
143147

144148
@property
145149
def tag(self) -> str:

0 commit comments

Comments
 (0)