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

Handling Type Errors From Standard Library numbers #5649

Closed
ImplyingICheck opened this issue Aug 5, 2023 · 1 comment
Closed

Handling Type Errors From Standard Library numbers #5649

ImplyingICheck opened this issue Aug 5, 2023 · 1 comment
Labels
enhancement request New feature or request

Comments

@ImplyingICheck
Copy link

Is your feature request related to a problem? Please describe.
The problem lies with _typeshed, not with pyright.

The numbers module is not meant to be used for typing. Since numbers is a part of the standard library, users of static type checkers might expect an ABC class to work for typing (at least I would).

Describe the solution you’d like
Would it make sense to display some form of warning when a type error arises from a numbers meta class? For reference, mypy currently implements this behaviour.

Another alternative, or potentially an additional change, would be to have a note about this in the pyright documentation.

Does this seem to be reasonable behaviour?

@ImplyingICheck ImplyingICheck added the enhancement request New feature or request label Aug 5, 2023
@erictraut
Copy link
Collaborator

We generally don't create special cases for specific classes or modules. The bar for adding special cases is very high, and I don't think this situation meets the bar.

The normal error messages in pyright should suffice to explain to users why they are seeing a type violation error, even if such an error initially may seem surprising.

I recall only a couple of cases where the current error messages have resulted in errant bug reports or questions by pyright users, so I don't think this is a widespread problem. I might consider revisiting this issue in the future if I see such a pattern.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement request New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants