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