Skip to content

sys.stdout.buffer has incorrect type? #2527

Open
@vlovich

Description

@vlovich

mypy test.py
test.py:10: error: Argument 1 to "test" has incompatible type "BinaryIO"; expected "BufferedIOBase"

cat test.py

import io
import sys

class C(io.BufferedIOBase):
  pass

def test(c: io.BufferedIOBase):
  assert isinstance(c, io.BufferedIOBase)

test(sys.stdout.buffer)
test(C())

python3 test.py

As we can see the isinstance check passes but mypy asserts

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: ioI/O related issues

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions