Skip to content

Update types to adhere to --strict-bytes / PEP688 #1305

@jakkdl

Description

@jakkdl

Mypy 1.16 added --strict-bytes to --strict, and plans to enable it by default in mypy 2.0. As far as I can tell the type hints in this package has not been updated to reflect this, giving false alarms for downstream users.

Pyright also does not promote bytearray/memoryview to bytes with disableBytesTypePromotions defaulting to True.

The one I noticed when updating pgjones/hypercorn#303 was H2Connection.receive_data only accepting bytes for the data parameter, but it only passes data onto FrameBuffer.add_data which should be perfectly capable of also accepting e.g. bytearray.

It's likely you can replace a lot of type hints with collections.abc.Buffer, or at least a protocol which inherits from Buffer + Sized (since FrameBuffer.add_data makes use of len).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions