Skip to content

Commit 6af50c0

Browse files
committed
Adapt code after updating to mypy 1.11
1 parent eaf553d commit 6af50c0

File tree

5 files changed

+6
-4
lines changed

5 files changed

+6
-4
lines changed

src/_pytest/_io/pprint.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,15 @@ def _format(
111111
p(self, object, stream, indent, allowance, context, level + 1)
112112
context.remove(objid)
113113
elif (
114-
_dataclasses.is_dataclass(object)
114+
_dataclasses.is_dataclass(object) # type:ignore[unreachable]
115115
and not isinstance(object, type)
116116
and object.__dataclass_params__.repr
117117
and
118118
# Check dataclass has generated repr method.
119119
hasattr(object.__repr__, "__wrapped__")
120120
and "__create_fn__" in object.__repr__.__wrapped__.__qualname__
121121
):
122-
context.add(objid)
122+
context.add(objid) # type:ignore[unreachable]
123123
self._pprint_dataclass(
124124
object, stream, indent, allowance, context, level + 1
125125
)

src/_pytest/capture.py

+1
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ def write(self, s: str) -> int:
202202
class DontReadFromInput(TextIO):
203203
@property
204204
def encoding(self) -> str:
205+
assert sys.__stdin__ is not None
205206
return sys.__stdin__.encoding
206207

207208
def read(self, size: int = -1) -> str:

src/_pytest/faulthandler.py

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ def get_stderr_fileno() -> int:
6464
# pytest-xdist monkeypatches sys.stderr with an object that is not an actual file.
6565
# https://docs.python.org/3/library/faulthandler.html#issue-with-file-descriptors
6666
# This is potentially dangerous, but the best we can do.
67+
assert sys.__stderr__ is not None
6768
return sys.__stderr__.fileno()
6869

6970

testing/test_assertion.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ def __setitem__(self, item, value):
823823
def __delitem__(self, item):
824824
pass
825825

826-
def insert(self, item, index):
826+
def insert(self, index, value):
827827
pass
828828

829829
expl = callequal(TestSequence([0, 1]), list([0, 2]))

testing/test_monkeypatch.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ def test_context() -> None:
415415
with monkeypatch.context() as m:
416416
m.setattr(functools, "partial", 3)
417417
assert not inspect.isclass(functools.partial)
418-
assert inspect.isclass(functools.partial)
418+
assert inspect.isclass(functools.partial) # type:ignore[unreachable]
419419

420420

421421
def test_context_classmethod() -> None:

0 commit comments

Comments
 (0)