-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add option to ignore code in if TYPE_CHECKING
#3285
Comments
Thanks, agree we should take more hints for |
I'm trying to preprocess the source code commenting our the imports guarded with TYPE_CHECKING, and then removing types with https://github.com/abarker/strip-hints. Otherwise, pylint would complain of the guarded types used in type hints. |
That bug allone makes it very inconvenient to keep using pylint on types projects, to a point where I am even considering removing it. Any chance we can have someone a patch to address it? |
if TYPE_CHECKING
This is a high priority issue but no one is working on it right now, if you're willing to contribute it could go faster 😄 |
Just a note: As a workaround, disable all checks for a block should help. from typing import TYPE_CHECKING
if TYPE_CHECKING:
# pylint: disable=all
from some_module import some_type |
Thanks for the clever trick @matusvalo ! For readers who also are would be implementer, this workaround would not work for circular imports for example, so we still need this feature very badly :) |
Is your feature request related to a problem? Please describe
In typed code, this is common pattern:
If
some_type
is defined in stub, it doesn't have to exist in runtime (e. g.wsgiref.types
is only available in.pyi
files). Pylint issues an error for this code, while it's perfectly valid.Pylint isn't a type checker, so it should ignore all code in
if TYPE_CHECKING:
.Describe the solution you'd like
Add option like to ignore all errors or, probably, only import-related errors in
if TYPE_CHECKING:
blocks.The text was updated successfully, but these errors were encountered: