Add test case for F401 in __init__ files (#10364)

In preparation for https://github.com/astral-sh/ruff/pull/5845
This commit is contained in:
Zanie Blue 2024-03-12 13:30:17 -05:00 committed by GitHub
parent 704fefc7ab
commit 87afe36c87
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 18 additions and 1 deletions

View file

@ -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(())

View file

@ -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 |