Skip to content

Commit a90c50d

Browse files
committed
test and snapshots
1 parent 067a08e commit a90c50d

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

crates/ruff_linter/src/rules/pyflakes/mod.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,26 @@ mod tests {
527527
import a",
528528
"f401_use_in_between_imports"
529529
)]
530+
#[test_case(
531+
r"
532+
if cond:
533+
import a
534+
import a.b
535+
a.foo()
536+
",
537+
"f401_same_branch"
538+
)]
539+
#[test_case(
540+
r"
541+
try:
542+
import a.b.c
543+
except ImportError:
544+
import argparse
545+
import a
546+
a.b = argparse.Namespace()
547+
",
548+
"f401_different_branch"
549+
)]
530550
fn f401_preview_refined_submodule_handling(contents: &str, snapshot: &str) {
531551
let diagnostics = test_contents(
532552
&SourceKind::Python(dedent(contents).to_string()),
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
source: crates/ruff_linter/src/rules/pyflakes/mod.rs
3+
---
4+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
source: crates/ruff_linter/src/rules/pyflakes/mod.rs
3+
---
4+
F401 [*] `a.b` imported but unused
5+
--> f401_preview_submodule.py:4:12
6+
|
7+
2 | if cond:
8+
3 | import a
9+
4 | import a.b
10+
| ^^^
11+
5 | a.foo()
12+
|
13+
help: Remove unused import: `a.b`
14+
1 |
15+
2 | if cond:
16+
3 | import a
17+
- import a.b
18+
4 | a.foo()

0 commit comments

Comments
 (0)