Skip to content

BufferedRWPair annotations #13495

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

Open
CodeMouse92 opened this issue Feb 12, 2025 · 0 comments
Open

BufferedRWPair annotations #13495

CodeMouse92 opened this issue Feb 12, 2025 · 0 comments
Labels
stubs: false positive Type checkers report false errors topic: io I/O related issues

Comments

@CodeMouse92
Copy link

Bug Report

It is typical to initialize an io.BufferedRWPair with the returns of Path.open() (in binary mode) as the arguments, and this works as expected.

BufferedRWPair(
        Path('readfrom.dat').open('rb'),
        Path('writeto.dat').open('wb')
)

To Reproduce

https://mypy-play.net/?mypy=latest&python=3.13&gist=79ee15dce5f93b8aa66a2a04c7bedcdc

Expected Behavior

Type checking should pass.

Actual Behavior

The type checking fails with:

error: Argument 1 to "BufferedRWPair" has incompatible type "BufferedReader"; expected "RawIOBase"  [arg-type]
error: Argument 2 to "BufferedRWPair" has incompatible type "BufferedWriter"; expected "RawIOBase"  [arg-type]

Your Environment

  • Mypy version used: 1.15.0
  • Mypy command-line flags:
  • Mypy configuration options from mypy.ini (and other config files):
[tool.mypy]
strict = true
  • Python version used: 3.13
@srittau srittau added stubs: false positive Type checkers report false errors topic: io I/O related issues labels Feb 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stubs: false positive Type checkers report false errors topic: io I/O related issues
Projects
None yet
Development

No branches or pull requests

2 participants