-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
option to enforce error codes in type: ignore
comments
#11509
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
Comments
Would also be useful if we could use # type: ignore below comments in the python file. Seems the # type: ignore is ignored if there is a license header in this format. Might be a separate bug/issue here. # license copyright info
"""This is a file""
# type: ignore This works. # type: ignore
# license copyright info
"""This is a file"" The above request seems more like a flake8 check? Maybe in https://pypi.org/project/flake8-annotations/ it would be simpler to implement? |
@asears What are you talking about? that code looks like a syntax error with an unterminated triple-quoted string. There are no types in that snipped so how could there be a type error? |
Just a typo in this github issue, in the full code there is a type error that isn't ignored with the first case and no typos/flake8 warnings. The problem can be reproduced by introducing a type error and trying to silence it with this: # license copyright info
"""This is a file"""
# type: ignore Adding the type: ignore to top of file works fine. |
@asears this seems unrelated to the proposal. Please open a new issue if you'd like to see a change in mypy. |
@asears are you asking for a whole file type ignore? In Kotlin annotations can target the file For mypy if that's what you want configure your pyproject.toml to specify the options you want, for eg: pyproject.toml: [[tool.mypy.overrides]]
module = "my.module"
ignore_errors = true |
How should this option interact with file-level |
@PeterJCLaw hmm, perhaps a separate option to prohibit file-level ignore comments? |
I would not worry about those. If you're using a file-level ignore, you probably want to ignore everything. |
Kotlin handles per code file wide suppression |
Feature
it would be cool if there was an option like
--disallow-ignore-without-code
or something that enforces error codes intype: ignore
commentsPitch
# type:ignore
comments risk suppressing an unintended error, which is why it's preferred to specify the exact error code you're suppressingThe text was updated successfully, but these errors were encountered: