I write a module for Salt. By the documentation it adds __salt__
object into builtins
. So, pyflake warn me that __salt__
is undefined when I run prospector and mypy says the same, that __salt__
is undefined! I can ignore either for pyflake with # noqa: F821
or for mypy with # type: ignore
on that line.
The question is! How to ignore for both of them?
You can use the form # type: ignore[<code>] to only ignore specific errors on the line.
You can use a special comment # type: ignore[code, ...] to only ignore errors with a specific error code (or codes) on a particular line. This can be used even if you have not configured mypy to show error codes. Currently it's only possible to disable arbitrary error codes on individual lines using this comment.
PEP 484 specifies towards the end of the section on type comments the following:
In some cases, linting tools or other comments may be needed on the same line as a type comment. In these cases, the type comment should be before other comments and linting markers:
# type: ignore # ~comment or other marker~
So, as Ryan Tam suggested, # type: ignore # noqa
is the correct way to ignore both.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With