Skip to content

Commit 6a8f6ed

Browse files
typing: Modernize type annotations on IO classes (#133487)
Remove unnecessary strings, use of Union[], use of List[], and reliance on implicit Optional. These type annotations are not actually used for anything but I feel we should set a good example.
1 parent 982830c commit 6a8f6ed

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

Lib/typing.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3477,7 +3477,7 @@ def readline(self, limit: int = -1) -> AnyStr:
34773477
pass
34783478

34793479
@abstractmethod
3480-
def readlines(self, hint: int = -1) -> List[AnyStr]:
3480+
def readlines(self, hint: int = -1) -> list[AnyStr]:
34813481
pass
34823482

34833483
@abstractmethod
@@ -3493,7 +3493,7 @@ def tell(self) -> int:
34933493
pass
34943494

34953495
@abstractmethod
3496-
def truncate(self, size: int = None) -> int:
3496+
def truncate(self, size: int | None = None) -> int:
34973497
pass
34983498

34993499
@abstractmethod
@@ -3505,11 +3505,11 @@ def write(self, s: AnyStr) -> int:
35053505
pass
35063506

35073507
@abstractmethod
3508-
def writelines(self, lines: List[AnyStr]) -> None:
3508+
def writelines(self, lines: list[AnyStr]) -> None:
35093509
pass
35103510

35113511
@abstractmethod
3512-
def __enter__(self) -> 'IO[AnyStr]':
3512+
def __enter__(self) -> IO[AnyStr]:
35133513
pass
35143514

35153515
@abstractmethod
@@ -3523,11 +3523,11 @@ class BinaryIO(IO[bytes]):
35233523
__slots__ = ()
35243524

35253525
@abstractmethod
3526-
def write(self, s: Union[bytes, bytearray]) -> int:
3526+
def write(self, s: bytes | bytearray) -> int:
35273527
pass
35283528

35293529
@abstractmethod
3530-
def __enter__(self) -> 'BinaryIO':
3530+
def __enter__(self) -> BinaryIO:
35313531
pass
35323532

35333533

@@ -3548,7 +3548,7 @@ def encoding(self) -> str:
35483548

35493549
@property
35503550
@abstractmethod
3551-
def errors(self) -> Optional[str]:
3551+
def errors(self) -> str | None:
35523552
pass
35533553

35543554
@property
@@ -3562,7 +3562,7 @@ def newlines(self) -> Any:
35623562
pass
35633563

35643564
@abstractmethod
3565-
def __enter__(self) -> 'TextIO':
3565+
def __enter__(self) -> TextIO:
35663566
pass
35673567

35683568

0 commit comments

Comments
 (0)