mirror of https://github.com/astral-sh/ruff
Remove preview gating for `pycodestyle` rules (#9685)
## Summary Un-gates the behavior to allow `sys.path` modifications between imports, which removed a bunch of false positives in the ecosystem CI at the time.
This commit is contained in:
parent
d81a76d1ef
commit
e201f45e5d
|
|
@ -342,8 +342,7 @@ where
|
|||
|| helpers::is_assignment_to_a_dunder(stmt)
|
||||
|| helpers::in_nested_block(self.semantic.current_statements())
|
||||
|| imports::is_matplotlib_activation(stmt, self.semantic())
|
||||
|| self.settings.preview.is_enabled()
|
||||
&& imports::is_sys_path_modification(stmt, self.semantic()))
|
||||
|| imports::is_sys_path_modification(stmt, self.semantic()))
|
||||
{
|
||||
self.semantic.flags |= SemanticModelFlags::IMPORT_BOUNDARY;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,7 +68,6 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test_case(Rule::IsLiteral, Path::new("constant_literals.py"))]
|
||||
#[test_case(Rule::ModuleImportNotAtTopOfFile, Path::new("E402_0.py"))]
|
||||
#[test_case(Rule::TypeComparison, Path::new("E721.py"))]
|
||||
fn preview_rules(rule_code: Rule, path: &Path) -> Result<()> {
|
||||
let snapshot = format!(
|
||||
|
|
|
|||
|
|
@ -1,36 +1,6 @@
|
|||
---
|
||||
source: crates/ruff_linter/src/rules/pycodestyle/mod.rs
|
||||
---
|
||||
E402_0.py:25:1: E402 Module level import not at top of file
|
||||
|
|
||||
23 | sys.path.insert(0, "some/path")
|
||||
24 |
|
||||
25 | import f
|
||||
| ^^^^^^^^ E402
|
||||
26 |
|
||||
27 | import matplotlib
|
||||
|
|
||||
|
||||
E402_0.py:27:1: E402 Module level import not at top of file
|
||||
|
|
||||
25 | import f
|
||||
26 |
|
||||
27 | import matplotlib
|
||||
| ^^^^^^^^^^^^^^^^^ E402
|
||||
28 |
|
||||
29 | matplotlib.use("Agg")
|
||||
|
|
||||
|
||||
E402_0.py:31:1: E402 Module level import not at top of file
|
||||
|
|
||||
29 | matplotlib.use("Agg")
|
||||
30 |
|
||||
31 | import g
|
||||
| ^^^^^^^^ E402
|
||||
32 |
|
||||
33 | __some__magic = 1
|
||||
|
|
||||
|
||||
E402_0.py:35:1: E402 Module level import not at top of file
|
||||
|
|
||||
33 | __some__magic = 1
|
||||
|
|
|
|||
|
|
@ -1,28 +0,0 @@
|
|||
---
|
||||
source: crates/ruff_linter/src/rules/pycodestyle/mod.rs
|
||||
---
|
||||
E402_0.py:35:1: E402 Module level import not at top of file
|
||||
|
|
||||
33 | __some__magic = 1
|
||||
34 |
|
||||
35 | import h
|
||||
| ^^^^^^^^ E402
|
||||
|
|
||||
|
||||
E402_0.py:45:1: E402 Module level import not at top of file
|
||||
|
|
||||
43 | import j
|
||||
44 |
|
||||
45 | import k; import l
|
||||
| ^^^^^^^^ E402
|
||||
|
|
||||
|
||||
E402_0.py:45:11: E402 Module level import not at top of file
|
||||
|
|
||||
43 | import j
|
||||
44 |
|
||||
45 | import k; import l
|
||||
| ^^^^^^^^ E402
|
||||
|
|
||||
|
||||
|
||||
Loading…
Reference in New Issue