← Back to index

directives_type_ignore_file2.py

True Positive
False Positive
False Negative
Optional (detected)
Warning or Info
TP: 1
FP: 0
FN: 0
Optional: 0 / 0
1"""
2Tests a file-level type ignore comment.
3"""
4
5# Specification: https://typing.readthedocs.io/en/latest/spec/directives.html#type-ignore-comments
6
7# type: ignore
[unused-type-ignore-comment] Unused blanket `type: ignore` directive
8
9# > A # type: ignore comment on a line by itself at the top of a file, before any
[unused-type-ignore-comment] Unused blanket `type: ignore` directive
10# > docstrings, imports, or other executable code, silences all errors in the file.
11# > Blank lines and other comments, such as shebang lines and coding cookies, may
12# > precede the # type: ignore comment.
[unused-type-ignore-comment] Unused blanket `type: ignore` directive
14x: int = "" # E: should still error because comment is not at top of file.
[invalid-assignment] Object of type `Literal[""]` is not assignable to `int`