python / mypy

Optional static typing for Python
https://www.mypy-lang.org/
Other
18.55k stars 2.84k forks source link

Config to disallow global `# type: ignore` and force ignoring specific errors #18127

Closed HansAarneLiblik closed 2 weeks ago

HansAarneLiblik commented 2 weeks ago

Feature

I'd like there to be a configuration option to disable usages of # type: ignore and force developers to use error specific ignores, like # type: ignore[assignment,misc]

Pitch

Ignoring everything does not make sense and is prone to errors when something is to be refactored. In my opinion, most ignores should also contain a comment why this ignore is used. Having specific errors is also helpful for these scenarios for visibility

hauntsaninja commented 2 weeks ago

https://mypy.readthedocs.io/en/stable/error_code_list2.html#check-that-type-ignore-include-an-error-code-ignore-without-code

HansAarneLiblik commented 2 weeks ago

Thanks! Indeed this works like a charm I thought it had to exist, but could not find it.

Keep up the awesome work