Skip to content

Commit 03ee641

Browse files
committed
Redefine type for BinaryIO.write in NamedTemporaryFileResult
1 parent feaa76a commit 03ee641

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/pip/_internal/utils/filesystem.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,22 @@
1717
from pip._internal.utils.typing import MYPY_CHECK_RUNNING, cast
1818

1919
if MYPY_CHECK_RUNNING:
20-
from typing import Any, BinaryIO, Iterator, List, Union
20+
import abc
21+
from typing import Any, BinaryIO, Iterator, List, Union, AnyStr
2122

2223
class NamedTemporaryFileResult(BinaryIO):
2324
@property
2425
def file(self):
2526
# type: () -> BinaryIO
2627
pass
2728

29+
# Redefine the type annotations of BinaryIO.write to accept
30+
# AnyStr as input instead of Union[bytes, bytearray]
31+
@abc.abstractmethod
32+
def write(self, s):
33+
# type: (AnyStr) -> int
34+
pass
35+
2836

2937
def check_path_owner(path):
3038
# type: (str) -> bool

0 commit comments

Comments
 (0)