Add invalid-ignore-comment rule (#15094)

This commit is contained in:
Micha Reiser
2024-12-23 11:38:10 +01:00
committed by GitHub
parent 2835d94ec5
commit 8d327087ef
4 changed files with 188 additions and 25 deletions

View File

@@ -117,6 +117,7 @@ a = 10 / 0 # knot: ignore[division-by-zero,]
```py
# error: [division-by-zero]
# error: [invalid-ignore-comment] "Invalid `knot: ignore` comment: expected a alphanumeric character or `-` or `_` as code"
a = 10 / 0 # knot: ignore[*-*]
```
@@ -138,9 +139,18 @@ future.
```py
# error: [unresolved-reference]
# error: [invalid-ignore-comment] "Invalid `knot: ignore` comment: expected a comma separating the rule codes"
a = x / 0 # knot: ignore[division-by-zero unresolved-reference]
```
## Missing closing bracket
```py
# error: [unresolved-reference] "Name `x` used when not defined"
# error: [invalid-ignore-comment] "Invalid `knot: ignore` comment: expected a comma separating the rule codes"
a = x / 2 # knot: ignore[unresolved-reference
```
## Empty codes
An empty codes array suppresses no-diagnostics and is always useless

View File

@@ -110,6 +110,7 @@ a = test \
```py
# error: [unresolved-reference]
# error: [invalid-ignore-comment]
a = test + 2 # type: ignoree
```