Skip to content

Conversation

@SpecLad
Copy link
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant