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

remove numbers module #8

Merged
merged 1 commit into from
Nov 27, 2023

Conversation

beauxq
Copy link
Contributor

@beauxq beauxq commented Nov 26, 2023

PEP https://peps.python.org/pep-0484/#the-numeric-tower
says there are issues with this numbers module.
In less formal places you can find python core maintainers (including Guido, the inventor of Python) saying that the numbers module was a mistake and you shouldn't use it.

You can always put an instance of int where a float belongs. So in most cases, you can use float for typing instead of numbers.Number.
For isinstance, it won't see an int as a float, so you can isinstance(n, (float, int))
If you find some other use case where that doesn't work, the official recommendation is to make a typing.Protocol specific for your use case.

for more information:
python/typing#272
python/mypy#3186
microsoft/pyright#1575

@charlesmadere charlesmadere merged commit b3e0e3c into charlesmadere:develop Nov 27, 2023
@charlesmadere
Copy link
Owner

@beauxq thank you!!!

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

Successfully merging this pull request may close these issues.

2 participants