mirror of https://github.com/astral-sh/ruff
[ty] Make `unused-ignore-comment` disabled by default for now (#17955)
This commit is contained in:
parent
6a5533c44c
commit
da8540862d
|
|
@ -4,3 +4,4 @@
|
||||||
# Enable off-by-default rules.
|
# Enable off-by-default rules.
|
||||||
[rules]
|
[rules]
|
||||||
possibly-unresolved-reference = "warn"
|
possibly-unresolved-reference = "warn"
|
||||||
|
unused-ignore-comment = "warn"
|
||||||
|
|
|
||||||
|
|
@ -59,13 +59,7 @@ type KeyDiagnosticFields = (
|
||||||
Severity,
|
Severity,
|
||||||
);
|
);
|
||||||
|
|
||||||
static EXPECTED_TOMLLIB_DIAGNOSTICS: &[KeyDiagnosticFields] = &[(
|
static EXPECTED_TOMLLIB_DIAGNOSTICS: &[KeyDiagnosticFields] = &[];
|
||||||
DiagnosticId::lint("unused-ignore-comment"),
|
|
||||||
Some("/src/tomllib/_parser.py"),
|
|
||||||
Some(22299..22333),
|
|
||||||
"Unused blanket `type: ignore` directive",
|
|
||||||
Severity::Warning,
|
|
||||||
)];
|
|
||||||
|
|
||||||
fn tomllib_path(file: &TestFile) -> SystemPathBuf {
|
fn tomllib_path(file: &TestFile) -> SystemPathBuf {
|
||||||
SystemPathBuf::from("src").join(file.name())
|
SystemPathBuf::from("src").join(file.name())
|
||||||
|
|
|
||||||
|
|
@ -1495,36 +1495,6 @@ a = 20 / 0 # ty: ignore[division-by-zero]
|
||||||
* [View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Fsuppression.rs#L40)
|
* [View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Fsuppression.rs#L40)
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
## `unused-ignore-comment`
|
|
||||||
|
|
||||||
**Default level**: warn
|
|
||||||
|
|
||||||
<details>
|
|
||||||
<summary>detects unused <code>type: ignore</code> comments</summary>
|
|
||||||
|
|
||||||
### What it does
|
|
||||||
Checks for `type: ignore` or `ty: ignore` directives that are no longer applicable.
|
|
||||||
|
|
||||||
### Why is this bad?
|
|
||||||
A `type: ignore` directive that no longer matches any diagnostic violations is likely
|
|
||||||
included by mistake, and should be removed to avoid confusion.
|
|
||||||
|
|
||||||
### Examples
|
|
||||||
```py
|
|
||||||
a = 20 / 2 # ty: ignore[division-by-zero]
|
|
||||||
```
|
|
||||||
|
|
||||||
Use instead:
|
|
||||||
|
|
||||||
```py
|
|
||||||
a = 20 / 2
|
|
||||||
```
|
|
||||||
|
|
||||||
### Links
|
|
||||||
* [Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20unused-ignore-comment)
|
|
||||||
* [View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Fsuppression.rs#L15)
|
|
||||||
</details>
|
|
||||||
|
|
||||||
## `possibly-unresolved-reference`
|
## `possibly-unresolved-reference`
|
||||||
|
|
||||||
**Default level**: ignore
|
**Default level**: ignore
|
||||||
|
|
@ -1552,3 +1522,33 @@ print(x) # NameError: name 'x' is not defined
|
||||||
* [View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L836)
|
* [View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L836)
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
|
## `unused-ignore-comment`
|
||||||
|
|
||||||
|
**Default level**: ignore
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>detects unused <code>type: ignore</code> comments</summary>
|
||||||
|
|
||||||
|
### What it does
|
||||||
|
Checks for `type: ignore` or `ty: ignore` directives that are no longer applicable.
|
||||||
|
|
||||||
|
### Why is this bad?
|
||||||
|
A `type: ignore` directive that no longer matches any diagnostic violations is likely
|
||||||
|
included by mistake, and should be removed to avoid confusion.
|
||||||
|
|
||||||
|
### Examples
|
||||||
|
```py
|
||||||
|
a = 20 / 2 # ty: ignore[division-by-zero]
|
||||||
|
```
|
||||||
|
|
||||||
|
Use instead:
|
||||||
|
|
||||||
|
```py
|
||||||
|
a = 20 / 2
|
||||||
|
```
|
||||||
|
|
||||||
|
### Links
|
||||||
|
* [Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20unused-ignore-comment)
|
||||||
|
* [View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Fsuppression.rs#L15)
|
||||||
|
</details>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -345,7 +345,7 @@ info: `lint:duplicate-base` is enabled by default
|
||||||
```
|
```
|
||||||
|
|
||||||
```
|
```
|
||||||
warning: lint:unused-ignore-comment
|
info: lint:unused-ignore-comment
|
||||||
--> src/mdtest_snippet.py:72:9
|
--> src/mdtest_snippet.py:72:9
|
||||||
|
|
|
|
||||||
70 | A,
|
70 | A,
|
||||||
|
|
@ -388,7 +388,7 @@ info: `lint:duplicate-base` is enabled by default
|
||||||
```
|
```
|
||||||
|
|
||||||
```
|
```
|
||||||
warning: lint:unused-ignore-comment
|
info: lint:unused-ignore-comment
|
||||||
--> src/mdtest_snippet.py:81:13
|
--> src/mdtest_snippet.py:81:13
|
||||||
|
|
|
|
||||||
79 | ):
|
79 | ):
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ declare_lint! {
|
||||||
pub(crate) static UNUSED_IGNORE_COMMENT = {
|
pub(crate) static UNUSED_IGNORE_COMMENT = {
|
||||||
summary: "detects unused `type: ignore` comments",
|
summary: "detects unused `type: ignore` comments",
|
||||||
status: LintStatus::preview("1.0.0"),
|
status: LintStatus::preview("1.0.0"),
|
||||||
default_level: Level::Warn,
|
default_level: Level::Ignore,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -813,7 +813,7 @@
|
||||||
"unused-ignore-comment": {
|
"unused-ignore-comment": {
|
||||||
"title": "detects unused `type: ignore` comments",
|
"title": "detects unused `type: ignore` comments",
|
||||||
"description": "## What it does\nChecks for `type: ignore` or `ty: ignore` directives that are no longer applicable.\n\n## Why is this bad?\nA `type: ignore` directive that no longer matches any diagnostic violations is likely\nincluded by mistake, and should be removed to avoid confusion.\n\n## Examples\n```py\na = 20 / 2 # ty: ignore[division-by-zero]\n```\n\nUse instead:\n\n```py\na = 20 / 2\n```",
|
"description": "## What it does\nChecks for `type: ignore` or `ty: ignore` directives that are no longer applicable.\n\n## Why is this bad?\nA `type: ignore` directive that no longer matches any diagnostic violations is likely\nincluded by mistake, and should be removed to avoid confusion.\n\n## Examples\n```py\na = 20 / 2 # ty: ignore[division-by-zero]\n```\n\nUse instead:\n\n```py\na = 20 / 2\n```",
|
||||||
"default": "warn",
|
"default": "ignore",
|
||||||
"oneOf": [
|
"oneOf": [
|
||||||
{
|
{
|
||||||
"$ref": "#/definitions/Level"
|
"$ref": "#/definitions/Level"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue