numerary
numerary copied to clipboard
`numpy` primitives no longer validate on assignment
Apparently, numpy upped its typing game, which is cool, but it makes it very hard to validate using something as rudimentary as numerary. Currently, the work-around I've found is something like the following:
# workaround.py
from numerary.types import SupportsFloorCeil
import numpy
uint8_val_typed: SupportsFloorCeil = numpy.uint8(2) # fails
uint8_val_asserted = numpy.uint8(2)
assert isinstance(uint8_val_asserted, SupportsFloorCeil) # works
reveal_type(uint8_val_asserted) # workaround.<subclass of "unsignedinteger" and "SupportsFloorCeil">
[deleted]