-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Testing which type checker is type checking the code #4292
Comments
I'm not aware of any discussions in the typing community about exposing the type checker to the code being type checked. There was a discussion a few years ago about exposing a way for code to determine which type checking features were supported by the type checker (e.g. You can effectively implement the solution you're proposing by defining your own value of Another option is to set I think that a |
This looks like a good solution for us.
I agree, but based on the discussion in python/mypy#12358 , it requires changes to |
A change to the AST isn't required to implement |
Is your feature request related to a problem? Please describe.
In testing pandas-stubs, we have code that fails mypy (because of a mypy bug), but not pyright. If we use
#type: ignore
comments to suppress the mypy errors, it also suppresses the pyright errors. Turns out that in one case,pyright
identified an error that we should fix without the#type: ignore
comments.Ideally, there would be some way of testing which type checker is being used (or mypy could implement a
# mypy: ignore
, but that doesn't seem to be happening any time soon - python/mypy#12358)Describe the solution you'd like
I realize that this kind of thing won't work at runtime or with another type checker, but I'm looking for a solution where I could say "pyright should type check this, but other type checkers should not", so I'm open to other ideas.
The only thing I've thought of is to have a constant that we import as
TYPE_CHECKER
, and then we patch that file in our CI before running each type checker.Has the typing community considered adding this feature (having a constant that indicates the label of the type checker) as a possible PDEP?
The text was updated successfully, but these errors were encountered: