Closed meggiman closed 1 year ago
Hi, thanks for the fix. I was actually looking at this just yesterday and read about the Self type for the first time, so it's useful to see it working.
Adding this would add a dependency on the external typing_extensions module, which I'm hesitant to do (perhaps I shouldn't be, but the next version of bitstring will be the first with any dependencies and I was hoping to keep it to just the one).
I'll take a look at what's the minimal I need to do when I get the chance, but a fix should go in for the next version.
Hi there, First of all, let me thank you for this amazing library. It is my go-to solution whenever I am manipulating binary data within EDA Python scripts. However, while cleaning up one of my repositories and adding static type checking, I noticed that there is some issue with the constructor type hinting in
bitstring
:The type hints of
Bits
's__new__
function are causing issues with the derived class ByteArray. Since ByteArray does not provide its own implementation of__new__
, it inherits the base classes version which is type hinted to always return aBits
instance. This causes issues during static type checking where now the following statement does not pass:Pylance/Pyright error:
Expression of type "Bits" cannot be assigned to declared type "BitArray"
I created a quick fix. See the linked PR below.