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

Enforce error codes on type: ignores #10718

Closed
TylerYep opened this issue Jun 26, 2021 · 5 comments
Closed

Enforce error codes on type: ignores #10718

TylerYep opened this issue Jun 26, 2021 · 5 comments
Labels

Comments

@TylerYep
Copy link

TylerYep commented Jun 26, 2021

Feature

As far as I know, there's no way to enforce an error code is added to the end of a type ignore. Since error codes can narrow the type errors ignored on a specific line, it would be useful to ensure all # type: ignores in a codebase included an error code, to avoid silencing additional errors or disabling otherwise valid typechecking on a line.

The feature could be a config option --enforce-error-codes that verifies all type: ignores specify an error code.

x: int = None  # type: ignore                <- mypy complains
x: int = None  # type: ignore[assignment]    <- good!
@AlexWaygood
Copy link
Member

AlexWaygood commented Mar 26, 2022

Implemented in #10712 (EDIT: linked the wrong PR accidentally, should have linked #11633)

@TylerYep
Copy link
Author

I don't think you linked a PR that adds this command line argument. Could you double check? Reopening.

@JelleZijlstra
Copy link
Member

It's #11633

@AlexWaygood
Copy link
Member

Whoops, my bad. Thanks @JelleZijlstra!

@TylerYep
Copy link
Author

TylerYep commented Mar 26, 2022

Ah, thanks!

Update: Realized it's enable_error_code = ignore-without-code

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

No branches or pull requests

3 participants