Skip to content

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

Closed
@JukkaL

Description

@JukkaL
Collaborator

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.

Activity

beauxq

beauxq commented on Feb 5, 2024

@beauxq

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.

hauntsaninja

hauntsaninja commented on Jun 22, 2024

@hauntsaninja
Collaborator

Fixed by #15137

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @JukkaL@beauxq@hauntsaninja

        Issue actions

          Generate an error if using a type from the numbers module · Issue #16874 · python/mypy