Skip to content

bytearray treated as a subclass of bytes #8505

Description

@llchan
  • Are you reporting a bug, or opening a feature request? bug
  • Please insert below the code you are checking with mypy
foo: bytes=bytearray()
assertisinstance(foo, bytes)
  • What is the actual behavior/output?
    No mypy error (and the expected AssertionError at runtime)
  • What is the behavior/output you expect?
    Mypy error about assigning wrong type (and the expected AssertionError at runtime)
  • What are the versions of mypy and Python you are using?
    mypy 0.761 on CPython 3.7.4
  • What are the mypy flags you are using? (For example --strict-optional)
    --strict

Typeshed appears to be fine, with bytes and bytearray both inheriting from ByteString, but no inheritance of bytearray from bytes.

classbytes(ByteString):
...
classbytearray(MutableSequence[int], ByteString):
...

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions