Skip to content

Commit 8c33c8f

Browse files
[mypy] Remove useless noqa, add noqa for new false positives
Co-authored-by: Sviatoslav Sydorenko (Святослав Сидоренко) <[email protected]>
1 parent a1b8697 commit 8c33c8f

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

src/_pytest/_io/pprint.py

Lines changed: 3 additions & 3 deletions
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) # type:ignore[unreachable]
114+
_dataclasses.is_dataclass(object)
115115
and not isinstance(object, type)
116-
and object.__dataclass_params__.repr
116+
and object.__dataclass_params__.repr # type:ignore[attr-defined]
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) # type:ignore[unreachable]
122+
context.add(objid)
123123
self._pprint_dataclass(
124124
object, stream, indent, allowance, context, level + 1
125125
)

src/_pytest/capture.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from typing import Any
1616
from typing import AnyStr
1717
from typing import BinaryIO
18+
from typing import cast
1819
from typing import Final
1920
from typing import final
2021
from typing import Generator
@@ -177,7 +178,8 @@ def name(self) -> str:
177178
def mode(self) -> str:
178179
# TextIOWrapper doesn't expose a mode, but at least some of our
179180
# tests check it.
180-
return self.buffer.mode.replace("b", "")
181+
assert hasattr(self.buffer, "mode")
182+
return cast(str, self.buffer.mode.replace("b", ""))
181183

182184

183185
class CaptureIO(io.TextIOWrapper):
@@ -550,7 +552,7 @@ def snap(self) -> bytes:
550552
res = self.tmpfile.buffer.read()
551553
self.tmpfile.seek(0)
552554
self.tmpfile.truncate()
553-
return res
555+
return res # type: ignore[return-value]
554556

555557
def writeorg(self, data: bytes) -> None:
556558
"""Write to original file descriptor."""

testing/test_runner.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ def raiser(exc):
137137
ss.teardown_exact(None)
138138
mod, func = e.value.exceptions
139139
assert isinstance(mod, KeyError)
140-
assert isinstance(func.exceptions[0], TypeError) # type: ignore
141-
assert isinstance(func.exceptions[1], ValueError) # type: ignore
140+
assert isinstance(func.exceptions[0], TypeError)
141+
assert isinstance(func.exceptions[1], ValueError)
142142

143143
def test_cached_exception_doesnt_get_longer(self, pytester: Pytester) -> None:
144144
"""Regression test for #12204 (the "BTW" case)."""

0 commit comments

Comments
 (0)