-
Notifications
You must be signed in to change notification settings - Fork 162
Description
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
).