Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

numpy primitives no longer validate on assignment #16

Open
posita opened this issue Jul 7, 2022 · 1 comment
Open

numpy primitives no longer validate on assignment #16

posita opened this issue Jul 7, 2022 · 1 comment

Comments

@posita
Copy link
Collaborator

posita commented Jul 7, 2022

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">
@posita
Copy link
Collaborator Author

posita commented Jul 7, 2022

[deleted]

@posita posita changed the title numpy primitives no longer validate numpy primitives no longer validate on assignment Jul 7, 2022
posita added a commit that referenced this issue Jul 7, 2022
posita added a commit that referenced this issue Oct 13, 2022
* Migrates from [``setuptools_scm``](https://pypi.org/project/setuptools-scm/) to [``versioningit``](https://pypi.org/project/versioningit/) for more flexible version number formatting.
* Adds work-around for ``numpy``’s typing updates ([#16](#16)).
* Allows deployments to PyPI from CI based on tags.
* Exposes ``CachingProtocolMeta`` ([#15](#15)).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant