mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-02 06:41:23 +00:00
Omit code frames for fixes with empty ranges (#12304)
## Summary Closes https://github.com/astral-sh/ruff/issues/12291. ## Test Plan ```shell ❯ cargo run check ../uv/foo --select INP /Users/crmarsh/workspace/uv/foo/bar/baz.py:1:1: INP001 File `/Users/crmarsh/workspace/uv/foo/bar/baz.py` is part of an implicit namespace package. Add an `__init__.py`. Found 1 error. ```
This commit is contained in:
parent
e58713e2ac
commit
940df67823
42 changed files with 11 additions and 457 deletions
|
@ -1259,9 +1259,6 @@ fn redirect_direct() {
|
|||
exit_code: 1
|
||||
----- stdout -----
|
||||
-:1:1: RUF950 Hey this is a test rule that was redirected from another.
|
||||
|
|
||||
|
|
||||
|
||||
Found 1 error.
|
||||
|
||||
----- stderr -----
|
||||
|
@ -1294,9 +1291,6 @@ fn redirect_prefix() {
|
|||
exit_code: 1
|
||||
----- stdout -----
|
||||
-:1:1: RUF950 Hey this is a test rule that was redirected from another.
|
||||
|
|
||||
|
|
||||
|
||||
Found 1 error.
|
||||
|
||||
----- stderr -----
|
||||
|
@ -1314,9 +1308,6 @@ fn deprecated_direct() {
|
|||
exit_code: 1
|
||||
----- stdout -----
|
||||
-:1:1: RUF920 Hey this is a deprecated test rule.
|
||||
|
|
||||
|
|
||||
|
||||
Found 1 error.
|
||||
|
||||
----- stderr -----
|
||||
|
@ -1334,13 +1325,7 @@ fn deprecated_multiple_direct() {
|
|||
exit_code: 1
|
||||
----- stdout -----
|
||||
-:1:1: RUF920 Hey this is a deprecated test rule.
|
||||
|
|
||||
|
|
||||
|
||||
-:1:1: RUF921 Hey this is another deprecated test rule.
|
||||
|
|
||||
|
|
||||
|
||||
Found 2 errors.
|
||||
|
||||
----- stderr -----
|
||||
|
@ -1359,13 +1344,7 @@ fn deprecated_indirect() {
|
|||
exit_code: 1
|
||||
----- stdout -----
|
||||
-:1:1: RUF920 Hey this is a deprecated test rule.
|
||||
|
|
||||
|
|
||||
|
||||
-:1:1: RUF921 Hey this is another deprecated test rule.
|
||||
|
|
||||
|
|
||||
|
||||
Found 2 errors.
|
||||
|
||||
----- stderr -----
|
||||
|
@ -1544,13 +1523,7 @@ fn check_hints_hidden_unsafe_fixes() {
|
|||
exit_code: 1
|
||||
----- stdout -----
|
||||
-:1:1: RUF901 [*] Hey this is a stable test rule with a safe fix.
|
||||
|
|
||||
|
|
||||
|
||||
-:1:1: RUF902 Hey this is a stable test rule with an unsafe fix.
|
||||
|
|
||||
|
|
||||
|
||||
Found 2 errors.
|
||||
[*] 1 fixable with the `--fix` option (1 hidden fix can be enabled with the `--unsafe-fixes` option).
|
||||
|
||||
|
@ -1568,11 +1541,6 @@ fn check_hints_hidden_unsafe_fixes_with_no_safe_fixes() {
|
|||
exit_code: 1
|
||||
----- stdout -----
|
||||
-:1:1: RUF902 Hey this is a stable test rule with an unsafe fix.
|
||||
|
|
||||
1 | x = {'a': 1, 'a': 1}
|
||||
| RUF902
|
||||
|
|
||||
|
||||
Found 1 error.
|
||||
No fixes available (1 hidden fix can be enabled with the `--unsafe-fixes` option).
|
||||
|
||||
|
@ -1591,13 +1559,7 @@ fn check_no_hint_for_hidden_unsafe_fixes_when_disabled() {
|
|||
exit_code: 1
|
||||
----- stdout -----
|
||||
-:1:1: RUF901 [*] Hey this is a stable test rule with a safe fix.
|
||||
|
|
||||
|
|
||||
|
||||
-:1:1: RUF902 Hey this is a stable test rule with an unsafe fix.
|
||||
|
|
||||
|
|
||||
|
||||
Found 2 errors.
|
||||
[*] 1 fixable with the --fix option.
|
||||
|
||||
|
@ -1617,11 +1579,6 @@ fn check_no_hint_for_hidden_unsafe_fixes_with_no_safe_fixes_when_disabled() {
|
|||
exit_code: 1
|
||||
----- stdout -----
|
||||
-:1:1: RUF902 Hey this is a stable test rule with an unsafe fix.
|
||||
|
|
||||
1 | x = {'a': 1, 'a': 1}
|
||||
| RUF902
|
||||
|
|
||||
|
||||
Found 1 error.
|
||||
|
||||
----- stderr -----
|
||||
|
@ -1639,13 +1596,7 @@ fn check_shows_unsafe_fixes_with_opt_in() {
|
|||
exit_code: 1
|
||||
----- stdout -----
|
||||
-:1:1: RUF901 [*] Hey this is a stable test rule with a safe fix.
|
||||
|
|
||||
|
|
||||
|
||||
-:1:1: RUF902 [*] Hey this is a stable test rule with an unsafe fix.
|
||||
|
|
||||
|
|
||||
|
||||
Found 2 errors.
|
||||
[*] 2 fixable with the --fix option.
|
||||
|
||||
|
@ -1667,11 +1618,6 @@ fn fix_applies_safe_fixes_by_default() {
|
|||
|
||||
----- stderr -----
|
||||
-:1:1: RUF902 Hey this is a stable test rule with an unsafe fix.
|
||||
|
|
||||
1 | # fix from stable-test-rule-safe-fix
|
||||
| RUF902
|
||||
|
|
||||
|
||||
Found 2 errors (1 fixed, 1 remaining).
|
||||
No fixes available (1 hidden fix can be enabled with the `--unsafe-fixes` option).
|
||||
"###);
|
||||
|
@ -1709,11 +1655,6 @@ fn fix_does_not_apply_display_only_fixes() {
|
|||
def add_to_list(item, some_list=[]): ...
|
||||
----- stderr -----
|
||||
-:1:1: RUF903 Hey this is a stable test rule with a display only fix.
|
||||
|
|
||||
1 | def add_to_list(item, some_list=[]): ...
|
||||
| RUF903
|
||||
|
|
||||
|
||||
Found 1 error.
|
||||
"###);
|
||||
}
|
||||
|
@ -1732,11 +1673,6 @@ fn fix_does_not_apply_display_only_fixes_with_unsafe_fixes_enabled() {
|
|||
def add_to_list(item, some_list=[]): ...
|
||||
----- stderr -----
|
||||
-:1:1: RUF903 Hey this is a stable test rule with a display only fix.
|
||||
|
|
||||
1 | def add_to_list(item, some_list=[]): ...
|
||||
| RUF903
|
||||
|
|
||||
|
||||
Found 1 error.
|
||||
"###);
|
||||
}
|
||||
|
@ -1754,9 +1690,6 @@ fn fix_only_unsafe_fixes_available() {
|
|||
|
||||
----- stderr -----
|
||||
-:1:1: RUF902 Hey this is a stable test rule with an unsafe fix.
|
||||
|
|
||||
|
|
||||
|
||||
Found 1 error.
|
||||
No fixes available (1 hidden fix can be enabled with the `--unsafe-fixes` option).
|
||||
"###);
|
||||
|
@ -1893,13 +1826,7 @@ extend-unsafe-fixes = ["RUF901"]
|
|||
exit_code: 1
|
||||
----- stdout -----
|
||||
-:1:1: RUF901 Hey this is a stable test rule with a safe fix.
|
||||
|
|
||||
|
|
||||
|
||||
-:1:1: RUF902 Hey this is a stable test rule with an unsafe fix.
|
||||
|
|
||||
|
|
||||
|
||||
Found 2 errors.
|
||||
No fixes available (2 hidden fixes can be enabled with the `--unsafe-fixes` option).
|
||||
|
||||
|
@ -1931,13 +1858,7 @@ extend-safe-fixes = ["RUF902"]
|
|||
exit_code: 1
|
||||
----- stdout -----
|
||||
-:1:1: RUF901 [*] Hey this is a stable test rule with a safe fix.
|
||||
|
|
||||
|
|
||||
|
||||
-:1:1: RUF902 [*] Hey this is a stable test rule with an unsafe fix.
|
||||
|
|
||||
|
|
||||
|
||||
Found 2 errors.
|
||||
[*] 2 fixable with the `--fix` option.
|
||||
|
||||
|
@ -1971,13 +1892,7 @@ extend-safe-fixes = ["RUF902"]
|
|||
exit_code: 1
|
||||
----- stdout -----
|
||||
-:1:1: RUF901 [*] Hey this is a stable test rule with a safe fix.
|
||||
|
|
||||
|
|
||||
|
||||
-:1:1: RUF902 Hey this is a stable test rule with an unsafe fix.
|
||||
|
|
||||
|
|
||||
|
||||
Found 2 errors.
|
||||
[*] 1 fixable with the `--fix` option (1 hidden fix can be enabled with the `--unsafe-fixes` option).
|
||||
|
||||
|
@ -2013,61 +1928,12 @@ extend-safe-fixes = ["RUF9"]
|
|||
exit_code: 1
|
||||
----- stdout -----
|
||||
-:1:1: RUF900 Hey this is a stable test rule.
|
||||
|
|
||||
1 | x = {'a': 1, 'a': 1}
|
||||
| RUF900
|
||||
2 | print(('foo'))
|
||||
3 | print(str('foo'))
|
||||
|
|
||||
|
||||
-:1:1: RUF901 Hey this is a stable test rule with a safe fix.
|
||||
|
|
||||
1 | x = {'a': 1, 'a': 1}
|
||||
| RUF901
|
||||
2 | print(('foo'))
|
||||
3 | print(str('foo'))
|
||||
|
|
||||
|
||||
-:1:1: RUF902 [*] Hey this is a stable test rule with an unsafe fix.
|
||||
|
|
||||
1 | x = {'a': 1, 'a': 1}
|
||||
| RUF902
|
||||
2 | print(('foo'))
|
||||
3 | print(str('foo'))
|
||||
|
|
||||
|
||||
-:1:1: RUF903 Hey this is a stable test rule with a display only fix.
|
||||
|
|
||||
1 | x = {'a': 1, 'a': 1}
|
||||
| RUF903
|
||||
2 | print(('foo'))
|
||||
3 | print(str('foo'))
|
||||
|
|
||||
|
||||
-:1:1: RUF920 Hey this is a deprecated test rule.
|
||||
|
|
||||
1 | x = {'a': 1, 'a': 1}
|
||||
| RUF920
|
||||
2 | print(('foo'))
|
||||
3 | print(str('foo'))
|
||||
|
|
||||
|
||||
-:1:1: RUF921 Hey this is another deprecated test rule.
|
||||
|
|
||||
1 | x = {'a': 1, 'a': 1}
|
||||
| RUF921
|
||||
2 | print(('foo'))
|
||||
3 | print(str('foo'))
|
||||
|
|
||||
|
||||
-:1:1: RUF950 Hey this is a test rule that was redirected from another.
|
||||
|
|
||||
1 | x = {'a': 1, 'a': 1}
|
||||
| RUF950
|
||||
2 | print(('foo'))
|
||||
3 | print(str('foo'))
|
||||
|
|
||||
|
||||
Found 7 errors.
|
||||
[*] 1 fixable with the `--fix` option (1 hidden fix can be enabled with the `--unsafe-fixes` option).
|
||||
|
||||
|
|
|
@ -116,14 +116,17 @@ impl Emitter for TextEmitter {
|
|||
)?;
|
||||
|
||||
if self.flags.intersects(EmitterFlags::SHOW_SOURCE) {
|
||||
writeln!(
|
||||
writer,
|
||||
"{}",
|
||||
MessageCodeFrame {
|
||||
message,
|
||||
notebook_index
|
||||
}
|
||||
)?;
|
||||
// The `0..0` range is used to highlight file-level diagnostics.
|
||||
if message.range() != TextRange::default() {
|
||||
writeln!(
|
||||
writer,
|
||||
"{}",
|
||||
MessageCodeFrame {
|
||||
message,
|
||||
notebook_index
|
||||
}
|
||||
)?;
|
||||
}
|
||||
}
|
||||
|
||||
if self.flags.intersects(EmitterFlags::SHOW_FIX_DIFF) {
|
||||
|
|
|
@ -2,9 +2,3 @@
|
|||
source: crates/ruff_linter/src/rules/flake8_copyright/mod.rs
|
||||
---
|
||||
<filename>:1:1: CPY001 Missing copyright notice at top of file
|
||||
|
|
||||
1 | কককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককক
|
||||
| CPY001
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -2,11 +2,3 @@
|
|||
source: crates/ruff_linter/src/rules/flake8_copyright/mod.rs
|
||||
---
|
||||
<filename>:1:1: CPY001 Missing copyright notice at top of file
|
||||
|
|
||||
1 | # Copyright (C) 2023 Some Author
|
||||
| CPY001
|
||||
2 |
|
||||
3 | import os
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -2,11 +2,3 @@
|
|||
source: crates/ruff_linter/src/rules/flake8_copyright/mod.rs
|
||||
---
|
||||
<filename>:1:1: CPY001 Missing copyright notice at top of file
|
||||
|
|
||||
1 | # Content Content Content Content Content Content Content Content Content Content
|
||||
| CPY001
|
||||
2 | # Content Content Content Content Content Content Content Content Content Content
|
||||
3 | # Content Content Content Content Content Content Content Content Content Content
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -2,9 +2,3 @@
|
|||
source: crates/ruff_linter/src/rules/flake8_copyright/mod.rs
|
||||
---
|
||||
<filename>:1:1: CPY001 Missing copyright notice at top of file
|
||||
|
|
||||
1 | # Copyright (C) 2022,2023 Ruff
|
||||
| CPY001
|
||||
2 |
|
||||
3 | import os
|
||||
|
|
||||
|
|
|
@ -2,9 +2,3 @@
|
|||
source: crates/ruff_linter/src/rules/flake8_copyright/mod.rs
|
||||
---
|
||||
<filename>:1:1: CPY001 Missing copyright notice at top of file
|
||||
|
|
||||
1 | # Copyright (C) 2022 , 2023 Ruff
|
||||
| CPY001
|
||||
2 |
|
||||
3 | import os
|
||||
|
|
||||
|
|
|
@ -2,9 +2,3 @@
|
|||
source: crates/ruff_linter/src/rules/flake8_copyright/mod.rs
|
||||
---
|
||||
<filename>:1:1: CPY001 Missing copyright notice at top of file
|
||||
|
|
||||
1 | # Copyright (C) 2022- 2023 Ruff
|
||||
| CPY001
|
||||
2 |
|
||||
3 | import os
|
||||
|
|
||||
|
|
|
@ -2,9 +2,3 @@
|
|||
source: crates/ruff_linter/src/rules/flake8_copyright/mod.rs
|
||||
---
|
||||
<filename>:1:1: CPY001 Missing copyright notice at top of file
|
||||
|
|
||||
1 | # Copyright (C) 2022 - 2023 Ruff
|
||||
| CPY001
|
||||
2 |
|
||||
3 | import os
|
||||
|
|
||||
|
|
|
@ -2,8 +2,3 @@
|
|||
source: crates/ruff_linter/src/rules/flake8_executable/mod.rs
|
||||
---
|
||||
EXE002_1.py:1:1: EXE002 The file is executable but no shebang is present
|
||||
|
|
||||
1 | if __name__ == '__main__':
|
||||
| EXE002
|
||||
2 | print('I should be executable.')
|
||||
|
|
||||
|
|
|
@ -2,7 +2,3 @@
|
|||
source: crates/ruff_linter/src/rules/flake8_no_pep420/mod.rs
|
||||
---
|
||||
example.py:1:1: INP001 File `./resources/test/fixtures/flake8_no_pep420/test_fail_empty/example.py` is part of an implicit namespace package. Add an `__init__.py`.
|
||||
|
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -2,9 +2,3 @@
|
|||
source: crates/ruff_linter/src/rules/flake8_no_pep420/mod.rs
|
||||
---
|
||||
example.py:1:1: INP001 File `./resources/test/fixtures/flake8_no_pep420/test_fail_nonempty/example.py` is part of an implicit namespace package. Add an `__init__.py`.
|
||||
|
|
||||
1 | print('hi')
|
||||
| INP001
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -2,14 +2,6 @@
|
|||
source: crates/ruff_linter/src/rules/isort/mod.rs
|
||||
---
|
||||
docstring.py:1:1: I002 [*] Missing required import: `from __future__ import annotations`
|
||||
|
|
||||
1 | """Hello, world!"""
|
||||
| I002
|
||||
2 |
|
||||
3 | x = 1
|
||||
|
|
||||
= help: Insert required import: `from __future__ import annotations`
|
||||
|
||||
ℹ Safe fix
|
||||
1 1 | """Hello, world!"""
|
||||
2 |+from __future__ import annotations
|
||||
|
@ -17,18 +9,8 @@ docstring.py:1:1: I002 [*] Missing required import: `from __future__ import anno
|
|||
3 4 | x = 1
|
||||
|
||||
docstring.py:1:1: I002 [*] Missing required import: `from __future__ import generator_stop`
|
||||
|
|
||||
1 | """Hello, world!"""
|
||||
| I002
|
||||
2 |
|
||||
3 | x = 1
|
||||
|
|
||||
= help: Insert required import: `from __future__ import generator_stop`
|
||||
|
||||
ℹ Safe fix
|
||||
1 1 | """Hello, world!"""
|
||||
2 |+from __future__ import generator_stop
|
||||
2 3 |
|
||||
3 4 | x = 1
|
||||
|
||||
|
||||
|
|
|
@ -2,18 +2,8 @@
|
|||
source: crates/ruff_linter/src/rules/isort/mod.rs
|
||||
---
|
||||
comment.py:1:1: I002 [*] Missing required import: `from __future__ import annotations`
|
||||
|
|
||||
1 | #!/usr/bin/env python3
|
||||
| I002
|
||||
2 |
|
||||
3 | x = 1
|
||||
|
|
||||
= help: Insert required import: `from __future__ import annotations`
|
||||
|
||||
ℹ Safe fix
|
||||
1 1 | #!/usr/bin/env python3
|
||||
2 |+from __future__ import annotations
|
||||
2 3 |
|
||||
3 4 | x = 1
|
||||
|
||||
|
||||
|
|
|
@ -2,13 +2,6 @@
|
|||
source: crates/ruff_linter/src/rules/isort/mod.rs
|
||||
---
|
||||
comments_and_newlines.py:1:1: I002 [*] Missing required import: `from __future__ import annotations`
|
||||
|
|
||||
1 | #!/usr/bin/env python3
|
||||
| I002
|
||||
2 | # A copyright notice could go here
|
||||
|
|
||||
= help: Insert required import: `from __future__ import annotations`
|
||||
|
||||
ℹ Safe fix
|
||||
2 2 | # A copyright notice could go here
|
||||
3 3 |
|
||||
|
@ -16,5 +9,3 @@ comments_and_newlines.py:1:1: I002 [*] Missing required import: `from __future__
|
|||
5 |+from __future__ import annotations
|
||||
5 6 |
|
||||
6 7 | x = 1
|
||||
|
||||
|
||||
|
|
|
@ -2,18 +2,8 @@
|
|||
source: crates/ruff_linter/src/rules/isort/mod.rs
|
||||
---
|
||||
docstring.py:1:1: I002 [*] Missing required import: `from __future__ import annotations`
|
||||
|
|
||||
1 | """Hello, world!"""
|
||||
| I002
|
||||
2 |
|
||||
3 | x = 1
|
||||
|
|
||||
= help: Insert required import: `from __future__ import annotations`
|
||||
|
||||
ℹ Safe fix
|
||||
1 1 | """Hello, world!"""
|
||||
2 |+from __future__ import annotations
|
||||
2 3 |
|
||||
3 4 | x = 1
|
||||
|
||||
|
||||
|
|
|
@ -2,16 +2,7 @@
|
|||
source: crates/ruff_linter/src/rules/isort/mod.rs
|
||||
---
|
||||
docstring_with_continuation.py:1:1: I002 [*] Missing required import: `from __future__ import annotations`
|
||||
|
|
||||
1 | """Hello, world!"""; x = \
|
||||
| I002
|
||||
2 | 1; y = 2
|
||||
|
|
||||
= help: Insert required import: `from __future__ import annotations`
|
||||
|
||||
ℹ Safe fix
|
||||
1 |-"""Hello, world!"""; x = \
|
||||
1 |+"""Hello, world!"""; from __future__ import annotations; x = \
|
||||
2 2 | 1; y = 2
|
||||
|
||||
|
||||
|
|
|
@ -2,14 +2,6 @@
|
|||
source: crates/ruff_linter/src/rules/isort/mod.rs
|
||||
---
|
||||
docstring_with_semicolon.py:1:1: I002 [*] Missing required import: `from __future__ import annotations`
|
||||
|
|
||||
1 | """Hello, world!"""; x = 1
|
||||
| I002
|
||||
|
|
||||
= help: Insert required import: `from __future__ import annotations`
|
||||
|
||||
ℹ Safe fix
|
||||
1 |-"""Hello, world!"""; x = 1
|
||||
1 |+"""Hello, world!"""; from __future__ import annotations; x = 1
|
||||
|
||||
|
||||
|
|
|
@ -2,16 +2,7 @@
|
|||
source: crates/ruff_linter/src/rules/isort/mod.rs
|
||||
---
|
||||
existing_import.py:1:1: I002 [*] Missing required import: `from __future__ import annotations`
|
||||
|
|
||||
1 | from __future__ import generator_stop
|
||||
| I002
|
||||
2 | import os
|
||||
|
|
||||
= help: Insert required import: `from __future__ import annotations`
|
||||
|
||||
ℹ Safe fix
|
||||
1 |+from __future__ import annotations
|
||||
1 2 | from __future__ import generator_stop
|
||||
2 3 | import os
|
||||
|
||||
|
||||
|
|
|
@ -2,19 +2,9 @@
|
|||
source: crates/ruff_linter/src/rules/isort/mod.rs
|
||||
---
|
||||
multiline_docstring.py:1:1: I002 [*] Missing required import: `from __future__ import annotations`
|
||||
|
|
||||
1 | """a
|
||||
| I002
|
||||
2 | b"""
|
||||
3 | # b
|
||||
|
|
||||
= help: Insert required import: `from __future__ import annotations`
|
||||
|
||||
ℹ Safe fix
|
||||
1 1 | """a
|
||||
2 2 | b"""
|
||||
3 3 | # b
|
||||
4 |+from __future__ import annotations
|
||||
4 5 | import os
|
||||
|
||||
|
||||
|
|
|
@ -2,19 +2,9 @@
|
|||
source: crates/ruff_linter/src/rules/isort/mod.rs
|
||||
---
|
||||
off.py:1:1: I002 [*] Missing required import: `from __future__ import annotations`
|
||||
|
|
||||
1 | # isort: off
|
||||
| I002
|
||||
2 |
|
||||
3 | x = 1
|
||||
|
|
||||
= help: Insert required import: `from __future__ import annotations`
|
||||
|
||||
ℹ Safe fix
|
||||
1 1 | # isort: off
|
||||
2 |+from __future__ import annotations
|
||||
2 3 |
|
||||
3 4 | x = 1
|
||||
4 5 | # isort: on
|
||||
|
||||
|
||||
|
|
|
@ -2,18 +2,8 @@
|
|||
source: crates/ruff_linter/src/rules/isort/mod.rs
|
||||
---
|
||||
comment.py:1:1: I002 [*] Missing required import: `from __future__ import annotations as _annotations`
|
||||
|
|
||||
1 | #!/usr/bin/env python3
|
||||
| I002
|
||||
2 |
|
||||
3 | x = 1
|
||||
|
|
||||
= help: Insert required import: `from __future__ import annotations as _annotations`
|
||||
|
||||
ℹ Safe fix
|
||||
1 1 | #!/usr/bin/env python3
|
||||
2 |+from __future__ import annotations as _annotations
|
||||
2 3 |
|
||||
3 4 | x = 1
|
||||
|
||||
|
||||
|
|
|
@ -2,13 +2,6 @@
|
|||
source: crates/ruff_linter/src/rules/isort/mod.rs
|
||||
---
|
||||
comments_and_newlines.py:1:1: I002 [*] Missing required import: `from __future__ import annotations as _annotations`
|
||||
|
|
||||
1 | #!/usr/bin/env python3
|
||||
| I002
|
||||
2 | # A copyright notice could go here
|
||||
|
|
||||
= help: Insert required import: `from __future__ import annotations as _annotations`
|
||||
|
||||
ℹ Safe fix
|
||||
2 2 | # A copyright notice could go here
|
||||
3 3 |
|
||||
|
@ -16,5 +9,3 @@ comments_and_newlines.py:1:1: I002 [*] Missing required import: `from __future__
|
|||
5 |+from __future__ import annotations as _annotations
|
||||
5 6 |
|
||||
6 7 | x = 1
|
||||
|
||||
|
||||
|
|
|
@ -2,18 +2,8 @@
|
|||
source: crates/ruff_linter/src/rules/isort/mod.rs
|
||||
---
|
||||
docstring.py:1:1: I002 [*] Missing required import: `from __future__ import annotations as _annotations`
|
||||
|
|
||||
1 | """Hello, world!"""
|
||||
| I002
|
||||
2 |
|
||||
3 | x = 1
|
||||
|
|
||||
= help: Insert required import: `from __future__ import annotations as _annotations`
|
||||
|
||||
ℹ Safe fix
|
||||
1 1 | """Hello, world!"""
|
||||
2 |+from __future__ import annotations as _annotations
|
||||
2 3 |
|
||||
3 4 | x = 1
|
||||
|
||||
|
||||
|
|
|
@ -2,16 +2,7 @@
|
|||
source: crates/ruff_linter/src/rules/isort/mod.rs
|
||||
---
|
||||
docstring_with_continuation.py:1:1: I002 [*] Missing required import: `from __future__ import annotations as _annotations`
|
||||
|
|
||||
1 | """Hello, world!"""; x = \
|
||||
| I002
|
||||
2 | 1; y = 2
|
||||
|
|
||||
= help: Insert required import: `from __future__ import annotations as _annotations`
|
||||
|
||||
ℹ Safe fix
|
||||
1 |-"""Hello, world!"""; x = \
|
||||
1 |+"""Hello, world!"""; from __future__ import annotations as _annotations; x = \
|
||||
2 2 | 1; y = 2
|
||||
|
||||
|
||||
|
|
|
@ -2,14 +2,6 @@
|
|||
source: crates/ruff_linter/src/rules/isort/mod.rs
|
||||
---
|
||||
docstring_with_semicolon.py:1:1: I002 [*] Missing required import: `from __future__ import annotations as _annotations`
|
||||
|
|
||||
1 | """Hello, world!"""; x = 1
|
||||
| I002
|
||||
|
|
||||
= help: Insert required import: `from __future__ import annotations as _annotations`
|
||||
|
||||
ℹ Safe fix
|
||||
1 |-"""Hello, world!"""; x = 1
|
||||
1 |+"""Hello, world!"""; from __future__ import annotations as _annotations; x = 1
|
||||
|
||||
|
||||
|
|
|
@ -2,16 +2,7 @@
|
|||
source: crates/ruff_linter/src/rules/isort/mod.rs
|
||||
---
|
||||
existing_import.py:1:1: I002 [*] Missing required import: `from __future__ import annotations as _annotations`
|
||||
|
|
||||
1 | from __future__ import generator_stop
|
||||
| I002
|
||||
2 | import os
|
||||
|
|
||||
= help: Insert required import: `from __future__ import annotations as _annotations`
|
||||
|
||||
ℹ Safe fix
|
||||
1 |+from __future__ import annotations as _annotations
|
||||
1 2 | from __future__ import generator_stop
|
||||
2 3 | import os
|
||||
|
||||
|
||||
|
|
|
@ -2,19 +2,9 @@
|
|||
source: crates/ruff_linter/src/rules/isort/mod.rs
|
||||
---
|
||||
multiline_docstring.py:1:1: I002 [*] Missing required import: `from __future__ import annotations as _annotations`
|
||||
|
|
||||
1 | """a
|
||||
| I002
|
||||
2 | b"""
|
||||
3 | # b
|
||||
|
|
||||
= help: Insert required import: `from __future__ import annotations as _annotations`
|
||||
|
||||
ℹ Safe fix
|
||||
1 1 | """a
|
||||
2 2 | b"""
|
||||
3 3 | # b
|
||||
4 |+from __future__ import annotations as _annotations
|
||||
4 5 | import os
|
||||
|
||||
|
||||
|
|
|
@ -2,19 +2,9 @@
|
|||
source: crates/ruff_linter/src/rules/isort/mod.rs
|
||||
---
|
||||
off.py:1:1: I002 [*] Missing required import: `from __future__ import annotations as _annotations`
|
||||
|
|
||||
1 | # isort: off
|
||||
| I002
|
||||
2 |
|
||||
3 | x = 1
|
||||
|
|
||||
= help: Insert required import: `from __future__ import annotations as _annotations`
|
||||
|
||||
ℹ Safe fix
|
||||
1 1 | # isort: off
|
||||
2 |+from __future__ import annotations as _annotations
|
||||
2 3 |
|
||||
3 4 | x = 1
|
||||
4 5 | # isort: on
|
||||
|
||||
|
||||
|
|
|
@ -2,14 +2,6 @@
|
|||
source: crates/ruff_linter/src/rules/isort/mod.rs
|
||||
---
|
||||
docstring.py:1:1: I002 [*] Missing required import: `from __future__ import annotations`
|
||||
|
|
||||
1 | """Hello, world!"""
|
||||
| I002
|
||||
2 |
|
||||
3 | x = 1
|
||||
|
|
||||
= help: Insert required import: `from __future__ import annotations`
|
||||
|
||||
ℹ Safe fix
|
||||
1 1 | """Hello, world!"""
|
||||
2 |+from __future__ import annotations
|
||||
|
@ -17,18 +9,8 @@ docstring.py:1:1: I002 [*] Missing required import: `from __future__ import anno
|
|||
3 4 | x = 1
|
||||
|
||||
docstring.py:1:1: I002 [*] Missing required import: `from __future__ import generator_stop`
|
||||
|
|
||||
1 | """Hello, world!"""
|
||||
| I002
|
||||
2 |
|
||||
3 | x = 1
|
||||
|
|
||||
= help: Insert required import: `from __future__ import generator_stop`
|
||||
|
||||
ℹ Safe fix
|
||||
1 1 | """Hello, world!"""
|
||||
2 |+from __future__ import generator_stop
|
||||
2 3 |
|
||||
3 4 | x = 1
|
||||
|
||||
|
||||
|
|
|
@ -2,18 +2,8 @@
|
|||
source: crates/ruff_linter/src/rules/isort/mod.rs
|
||||
---
|
||||
docstring.py:1:1: I002 [*] Missing required import: `import os`
|
||||
|
|
||||
1 | """Hello, world!"""
|
||||
| I002
|
||||
2 |
|
||||
3 | x = 1
|
||||
|
|
||||
= help: Insert required import: `import os`
|
||||
|
||||
ℹ Safe fix
|
||||
1 1 | """Hello, world!"""
|
||||
2 |+import os
|
||||
2 3 |
|
||||
3 4 | x = 1
|
||||
|
||||
|
||||
|
|
|
@ -2,18 +2,8 @@
|
|||
source: crates/ruff_linter/src/rules/isort/mod.rs
|
||||
---
|
||||
docstring.pyi:1:1: I002 [*] Missing required import: `import os`
|
||||
|
|
||||
1 | """Hello, world!"""
|
||||
| I002
|
||||
2 |
|
||||
3 | x = 1
|
||||
|
|
||||
= help: Insert required import: `import os`
|
||||
|
||||
ℹ Safe fix
|
||||
1 1 | """Hello, world!"""
|
||||
2 |+import os
|
||||
2 3 |
|
||||
3 4 | x = 1
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,3 @@
|
|||
source: crates/ruff_linter/src/rules/pep8_naming/mod.rs
|
||||
---
|
||||
__init__.py:1:1: N999 Invalid module name: 'MODULE'
|
||||
|
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,3 @@
|
|||
source: crates/ruff_linter/src/rules/pep8_naming/mod.rs
|
||||
---
|
||||
0001_initial.py:1:1: N999 Invalid module name: '0001_initial'
|
||||
|
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,3 @@
|
|||
source: crates/ruff_linter/src/rules/pep8_naming/mod.rs
|
||||
---
|
||||
import.py:1:1: N999 Invalid module name: 'import'
|
||||
|
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,3 @@
|
|||
source: crates/ruff_linter/src/rules/pep8_naming/mod.rs
|
||||
---
|
||||
__init__.py:1:1: N999 Invalid module name: 'mod with spaces'
|
||||
|
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,3 @@
|
|||
source: crates/ruff_linter/src/rules/pep8_naming/mod.rs
|
||||
---
|
||||
__init__.py:1:1: N999 Invalid module name: 'mod-with-dashes'
|
||||
|
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,3 @@
|
|||
source: crates/ruff_linter/src/rules/pep8_naming/mod.rs
|
||||
---
|
||||
file-with-dashes.py:1:1: N999 Invalid module name: 'file-with-dashes'
|
||||
|
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -2,11 +2,3 @@
|
|||
source: crates/ruff_linter/src/rules/pydocstyle/mod.rs
|
||||
---
|
||||
D.py:1:1: D100 Missing docstring in public module
|
||||
|
|
||||
1 | # No docstring, so we can test D100
|
||||
| D100
|
||||
2 | from functools import wraps
|
||||
3 | import os
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,3 @@
|
|||
source: crates/ruff_linter/src/rules/pydocstyle/mod.rs
|
||||
---
|
||||
D100_pub.py:1:1: D100 Missing docstring in public module
|
||||
|
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,3 @@
|
|||
source: crates/ruff_linter/src/rules/pydocstyle/mod.rs
|
||||
---
|
||||
__init__.py:1:1: D104 Missing docstring in public package
|
||||
|
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -2,12 +2,6 @@
|
|||
source: crates/ruff_linter/src/rules/pydocstyle/mod.rs
|
||||
---
|
||||
all.py:1:1: D100 Missing docstring in public module
|
||||
|
|
||||
1 | def public_func():
|
||||
| D100
|
||||
2 | pass
|
||||
|
|
||||
|
||||
all.py:1:5: D103 Missing docstring in public function
|
||||
|
|
||||
1 | def public_func():
|
||||
|
@ -30,5 +24,3 @@ all.py:10:11: D106 Missing docstring in public nested class
|
|||
| ^^^^^^^^^^^^^^^^^ D106
|
||||
11 | pass
|
||||
|
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue