]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-108411: Make typing.IO/BinaryIO arguments positional-only (#142906) main
authorRoman Donchenko <rdonchen@outlook.com>
Mon, 20 Apr 2026 20:19:43 +0000 (23:19 +0300)
committerGitHub <noreply@github.com>
Mon, 20 Apr 2026 20:19:43 +0000 (13:19 -0700)
commitf6ed7c0acbd9234226cab5cca12f9d312809103e
tree31efaadd3bb424ddfbb9c60d22c2eaf32aa06f38
parent9a1c70c639f2ac60ae3756bec20c2584303f748e
gh-108411: Make typing.IO/BinaryIO arguments positional-only (#142906)

`IO` is purported to be the type of the file objects returned by `open`.
However, all methods on those objects take positional-only arguments, while
`IO`'s methods are declared with regular arguments. As such, the file objects
cannot actually be considered to implement `IO`. The same thing applies to
`BinaryIO`.

Fix this by adjusting the definition of these ABCs to match the file objects.

This is technically a breaking change, but it is unlikely to actually break
anything:

* These methods should never be called at runtime, since they are abstract.
  Therefore, this should not cause any runtime errors.

* In typeshed these arguments are already positional-only, so this should
  not cause any errors during typechecking either.
Lib/typing.py
Misc/NEWS.d/next/Library/2025-12-17-02-55-03.gh-issue-108411.up7MAc.rst [new file with mode: 0644]