Skip to content

numpy primitives no longer validate on assignment #16

@posita

Description

@posita

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">

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions