Skip to content

Ignoring an entire file #964

@JukkaL

Description

@JukkaL

Edit from 2023: Do not do this.

See the following instead:


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.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions