'can i tell mypy to warn me on type ignores without error codes, only *# type: ignore[code, ...]* should be accepted
I would like to have all type-ignores with errorcodes # type: ignore[code, ...]
and disallow # type: ignore
without them.
I checked the docs but could not find what I am looking for.
Is there any option that allows me to do that? I could write my own script to do that, but if mypy can do that I would prefer that.
Something like warn_type_ignore_without_errorcode = True
?
Solution 1:[1]
This has been added from mypy 0.40 with the ignore-without-code
check. Enable it in-code with:
# mypy: enable-error-code ignore-without-code
Or add it to your pyproject.toml file with:
[tool.mypy]
enable_error_code = "ignore-without-code"
Or add it to your mypy.ini file with:
[mypy]
enable_error_code = ignore-without-code
Reference:
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |