Skip to content

Commit

Permalink
fix(F822): do not skip warnings in __init__.py
Browse files Browse the repository at this point in the history
  • Loading branch information
hassec committed May 16, 2024
1 parent 4436dec commit 31f6f9b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 11 deletions.
20 changes: 9 additions & 11 deletions crates/ruff_linter/src/checkers/ast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2299,17 +2299,15 @@ impl<'a> Checker<'a> {
}
} else {
if self.enabled(Rule::UndefinedExport) {
if !self.path.ends_with("__init__.py") {
self.diagnostics.push(
Diagnostic::new(
pyflakes::rules::UndefinedExport {
name: name.to_string(),
},
range,
)
.with_parent(definition.start()),
);
}
self.diagnostics.push(
Diagnostic::new(
pyflakes::rules::UndefinedExport {
name: name.to_string(),
},
range,
)
.with_parent(definition.start()),
);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,27 @@ __init__.py:1:8: F401 `os` imported but unused; consider removing, adding to `__
3 | print(__path__)
|
= help: Remove unused import: `os`

__init__.py:5:12: F822 Undefined name `a` in `__all__`
|
3 | print(__path__)
4 |
5 | __all__ = ["a", "b", "c"]
| ^^^ F822
|

__init__.py:5:17: F822 Undefined name `b` in `__all__`
|
3 | print(__path__)
4 |
5 | __all__ = ["a", "b", "c"]
| ^^^ F822
|

__init__.py:5:22: F822 Undefined name `c` in `__all__`
|
3 | print(__path__)
4 |
5 | __all__ = ["a", "b", "c"]
| ^^^ F822
|

0 comments on commit 31f6f9b

Please sign in to comment.