Skip to content

Commit

Permalink
Add test case for F401 in __init__ files (#10364)
Browse files Browse the repository at this point in the history
In preparation for #5845
  • Loading branch information
zanieb committed Mar 12, 2024
1 parent 704fefc commit 87afe36
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
6 changes: 5 additions & 1 deletion crates/ruff_linter/src/rules/pyflakes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,11 @@ mod tests {
fn init() -> Result<()> {
let diagnostics = test_path(
Path::new("pyflakes/__init__.py"),
&LinterSettings::for_rules(vec![Rule::UndefinedName, Rule::UndefinedExport]),
&LinterSettings::for_rules(vec![
Rule::UndefinedName,
Rule::UndefinedExport,
Rule::UnusedImport,
]),
)?;
assert_messages!(diagnostics);
Ok(())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
---
source: crates/ruff_linter/src/rules/pyflakes/mod.rs
---
__init__.py:1:8: F401 [*] `os` imported but unused
|
1 | import os
| ^^ F401
2 |
3 | print(__path__)
|
= help: Remove unused import: `os`

Safe fix
1 |-import os
2 1 |
3 2 | print(__path__)
4 3 |

0 comments on commit 87afe36

Please sign in to comment.