Skip to content

Commit 3fa2fa4

Browse files
Update src/_pytest/capture.py
Co-authored-by: Sviatoslav Sydorenko (Святослав Сидоренко) <[email protected]>
1 parent 38211b8 commit 3fa2fa4

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/_pytest/capture.py

Lines changed: 3 additions & 1 deletion
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", "") # type: ignore[no-any-return,attr-defined]
181+
assert hasattr(self.buffer, "mode")
182+
return cast(str, self.buffer.mode.replace("b", ""))
181183

182184

183185
class CaptureIO(io.TextIOWrapper):

0 commit comments

Comments
 (0)