-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Description
Edit from 2023: Do not do this.
See the following instead:
- https://mypy.readthedocs.io/en/stable/type_inference_and_annotations.html#other-ways-to-silence-errors
- https://mypy.readthedocs.io/en/stable/common_issues.html#ignoring-a-whole-file
A # type: ignore
at the top level of the module should ignore errors in the entire file.
Example:
# type: ignore
1 + 'x' # no error reported!
We should still try to semantically analyze the file for some level of checking for code that uses the module, such as function argument count checking. It's not obvious whether this is always desirable, as the semantic analyzer might miss some definitions and cause false positives elsewhere.
All type annotations in the file should be ignored and not even parsed for PEP 484 conformance.
Let's require the comment to be at the beginning of a file, before the first non string literal token (before or after the docstring).
If we can't fully parse the file (but can analyze it enough to detect the # type: ignore
comment) we shouldn't generate an error but basically implicitly act as if there was # type: ignore
everywhere where the module is imported, and treat the module as unknown/missing.