Skip to content

gh-108411: Make typing.IO/BinaryIO arguments positional-only#142906

Merged
JelleZijlstra merged 1 commit intopython:mainfrom
SpecLad:io-positional-only
Apr 20, 2026
Merged

gh-108411: Make typing.IO/BinaryIO arguments positional-only#142906
JelleZijlstra merged 1 commit intopython:mainfrom
SpecLad:io-positional-only

Conversation

@SpecLad
Copy link
Copy Markdown
Contributor

@SpecLad SpecLad commented Dec 17, 2025

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.

`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.
@SpecLad
Copy link
Copy Markdown
Contributor Author

SpecLad commented Apr 20, 2026

@JelleZijlstra Is there anything else that needs to be done to get this merged?

@JelleZijlstra JelleZijlstra merged commit f6ed7c0 into python:main Apr 20, 2026
52 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants