← Back to index
directives_type_ignore.py
True Positive
False Positive
False Negative
Optional (detected)
Warning or Info
TP: 0
FP: 1
FN: 0
Optional: 0 / 0
1
"""
2
Tests
"# type: ignore"
comments
.
3
"""
4
5
# Specification: https://typing.readthedocs.io/en/latest/spec/directives.html#type-ignore-comments
6
7
# The following type violation should be suppressed.
8
x
:
int
=
""
# type: ignore
9
10
# The following type violation should be suppressed.
11
y
:
int
=
""
# type: ignore - additional stuff
12
13
# The following type violation should be suppressed.
14
z
:
int
=
""
# type: ignore[additional_stuff]
Unexpected error [invalid-assignment] Object of type `Literal[""]` is not assignable to `int`
15
16
# > In some cases, linting tools or other comments may be needed on the same
17
# > line as a type comment. In these cases, the type comment should be before
18
# > other comments and linting markers.
19
20
a
:
int
=
""
# type: ignore # other comment