Skip to content

typing: Modernize type annotations on IO classes #133487

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions Lib/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -3477,7 +3477,7 @@ def readline(self, limit: int = -1) -> AnyStr:
pass

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

@abstractmethod
Expand All @@ -3493,7 +3493,7 @@ def tell(self) -> int:
pass

@abstractmethod
def truncate(self, size: int = None) -> int:
def truncate(self, size: int | None = None) -> int:
pass

@abstractmethod
Expand All @@ -3505,11 +3505,11 @@ def write(self, s: AnyStr) -> int:
pass

@abstractmethod
def writelines(self, lines: List[AnyStr]) -> None:
def writelines(self, lines: list[AnyStr]) -> None:
pass

@abstractmethod
def __enter__(self) -> 'IO[AnyStr]':
def __enter__(self) -> IO[AnyStr]:
pass

@abstractmethod
Expand All @@ -3523,11 +3523,11 @@ class BinaryIO(IO[bytes]):
__slots__ = ()

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

@abstractmethod
def __enter__(self) -> 'BinaryIO':
def __enter__(self) -> BinaryIO:
pass


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

@property
@abstractmethod
def errors(self) -> Optional[str]:
def errors(self) -> str | None:
pass

@property
Expand All @@ -3562,7 +3562,7 @@ def newlines(self) -> Any:
pass

@abstractmethod
def __enter__(self) -> 'TextIO':
def __enter__(self) -> TextIO:
pass


Expand Down
Loading