Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Open
@jakkdl

Description

This is a near copy-paste of python-hyper/h2#1305

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 Connection.receive_data only accepting bytes for the data parameter, but it only passes data onto ReceiveBuffer.__iadd__ which explicitly accepts bytes | bytearray. Even this could be widened, as bytearray.__iadd__ effectively accepts Buffer (though I'm not sure if the ReadableBuffer distinction matters, probably not)

It's likely you can replace a lot of type hints with collections.abc.Buffer, or other protocols.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /