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 with
8d2c79276d/crates/ruff_linter/resources/test/fixtures/pyflakes/F404_0.py (L1-L8)
and
8d2c79276d/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:
Max Mynter 2025-04-25 14:32:57 +02:00 committed by GitHub
parent afc18ff1a1
commit 3f84e75e20
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 12 additions and 0 deletions

View file

@ -0,0 +1,2 @@
import random
from __future__ import annotations # Error; not at top of file

View 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(

View file

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