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

Generate an error if using a type from the numbers module #16874

Open
JukkaL opened this issue Feb 5, 2024 · 1 comment
Open

Generate an error if using a type from the numbers module #16874

JukkaL opened this issue Feb 5, 2024 · 1 comment

Comments

@JukkaL
Copy link
Collaborator

JukkaL commented Feb 5, 2024

Feature

Generate an error if a type from the stdlib numbers module is used in an annotation. Use a dedicated error code so that the error can be easily enabled and disabled. Initially this would be disabled by default, but we'd enable it by default in the next major mypy release.

Pitch

These types are very rarely useful for static type checking but often cause confusion when users try to use them. If we'd generate an error by default with a clarifying note, users would be less likely to go down this rabbit hole. Any existing, legitimate use cases (which I expect to be rare) would still be supported by explicitly disabling the error code.

This would be an alternative way to approach #3186.

@beauxq
Copy link

beauxq commented Feb 5, 2024

I recently had a friend (kind of new to Python and and Python typing) start using some of those numbers types.

Remembering some of my past experiences with it, I said to him "No, no. You don't want to do that."

And my mistake of using the numbers module years ago is still stuck making a mess in another project, where we have to keep it for backwards compatibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants