mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 18:58:04 +00:00
Add Semantic Error Test for LateFutureImport (#17612)
Adresses a question in #17526. ## Summary Adds a syntax error test for `__future__` import not at top of file. ## Question: Is this a redundant with8d2c79276d/crates/ruff_linter/resources/test/fixtures/pyflakes/F404_0.py (L1-L8)
and8d2c79276d/crates/ruff_linter/resources/test/fixtures/pyflakes/F404_1.py (L1-L5)
which test pyflake `F404`? <!-- What's the purpose of the change? What does it do, and why? --> ## Test Plan This is a test <!-- How was it tested? -->
This commit is contained in:
parent
afc18ff1a1
commit
3f84e75e20
3 changed files with 12 additions and 0 deletions
2
crates/ruff_linter/resources/test/fixtures/syntax_errors/late_future_import.py
vendored
Normal file
2
crates/ruff_linter/resources/test/fixtures/syntax_errors/late_future_import.py
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
import random
|
||||
from __future__ import annotations # Error; not at top of file
|
|
@ -1062,6 +1062,7 @@ mod tests {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[test_case(Rule::LateFutureImport, Path::new("late_future_import.py"))]
|
||||
#[test_case(Rule::YieldOutsideFunction, Path::new("yield_scope.py"))]
|
||||
#[test_case(Rule::ReturnOutsideFunction, Path::new("return_outside_function.py"))]
|
||||
#[test_case(
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
---
|
||||
source: crates/ruff_linter/src/linter.rs
|
||||
---
|
||||
resources/test/fixtures/syntax_errors/late_future_import.py:2:1: F404 `from __future__` imports must occur at the beginning of the file
|
||||
|
|
||||
1 | import random
|
||||
2 | from __future__ import annotations # Error; not at top of file
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F404
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue