Type check errors can be suppressed by a knot: ignore comment on the same line as the violation.
a = 4 + test # knot: ignorea = 4 + test # knot: ignore[unresolved-reference]TODO: Red Knot should emit an unused-suppression diagnostic for the
possibly-unresolved-reference suppression.
test = 10
a = test + 3 # knot: ignore[possibly-unresolved-reference]TODO: Red Knot should emit a unused-suppression diagnostic for the possibly-unresolved-reference
suppression because it doesn't match the actual unresolved-reference diagnostic.
# error: [unresolved-reference]
a = test + 3 # knot: ignore[possibly-unresolved-reference]# fmt: off
def test(a: f"f-string type annotation", b: b"byte-string-type-annotation"): ... # knot: ignore[fstring-type-annotation, byte-string-type-annotation]# error: [invalid-syntax]
def test( # knot: ignorea = 10
# revealed: Literal[10]
reveal_type(a) # knot: ignorea = 10 / 0 # knot : ignore
a = 10 / 0 # knot: ignore [ division-by-zero ]# fmt: off
a = 10 / 0 #knot:ignore[division-by-zero]Trailing commas in the codes section are allowed:
a = 10 / 0 # knot: ignore[division-by-zero,]# error: [division-by-zero]
a = 10 / 0 # knot: ignore[*-*]a = 10 / 0 # knot: ignore[division-by-zero]
# ^^^^^^ trailing whitespaceA missing comma results in an invalid suppression comment. We may want to recover from this in the future.
# error: [unresolved-reference]
a = x / 0 # knot: ignore[division-by-zero unresolved-reference]An empty codes array suppresses no-diagnostics and is always useless
# error: [division-by-zero]
a = 4 / 0 # knot: ignore[]