I am trying to silence mypy errors based on error codes. This is done using something like this:
from foolib import foo # type: ignore[attr-defined]
I believe PyCharm is interpreting my type: ignore[code]
comments as a type comment, and reporting ignore
as an unresolved reference.
Also, PyCharm expects an expression within the brackets.
mypy
error I'm trying to suppress:
pylint_ignore.py:8: error: Skipping analyzing 'pylint.utils': found module but no type hints or library stubs [import]
And yes, I know I can just say type: ignore
, and not include a code, or specify to ignore this particular import in a config file. However, I would like to specify the error codes, because I think it's a good feature.
How can I get PyCharm not to complain about this?
Research
This answer to How do I stop pyCharm from complaining about underscore strings?
Helped me realize under Preferences --> Editor --> Inspections --> Python --> Unresolved references
, I can add a fully qualified symbol name to be ignored.
I believe this is officially documented here.
I tried adding *.ignore.*
(since I don't want to have to build up a per-module ignore list), but this didn't work.
If this is the right approach, can you help me figure out the right syntax?
Versions
mypy==0.770
python==3.6.5
PyCharm PE 2020.1