Closed prauscher closed 1 year ago
Hi. Yes you're right that there are probably a few methods that could use some more explicit overloading hints. Thanks for pointing this out.
After a bit of trial and error, the best I could do was to use an Any
to sooth the mypy gods:
@overload
def read(self, fmt: int) -> Bits: ...
@overload
def read(self, fmt: str) -> Any: ...
def read(self, fmt: Union[int, str]) -> Union[int, float, str, Bits, bool, bytes, None]:
I'm fine with that as there's no way to statically work out the return type if its reading a format str
.
Done in the 4.1 beta now available.
Currently, the signature of
BitStream.read
is given asThis leads to problems when using:
Which is obviously invalid, as both calls will work with integers. One solution would be to use
@overload
e.g.