No error about `__future__` import placed after some statements
Open
Nobody has claimed this yet.
bug
topic-runtime-semantics
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
print('Hello')
from __future__ import annotations
At runtime i get SyntaxError:
File "D:\_.py", line 2
from __future__ import annotations
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: from __future__ imports must occur at the beginning of the file
Expected Behavior
invalid syntaxerror
Actual Behavior
- no errors
Your Environment
mypy 1.0.0+dev.db0beb1014d8367221d47d3b11e2b49e757fa2fa (compiled: no)(almost latest currently)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating mypy's handling of future imports and its existing diagnostics or tests for import placement. Reproduce the reported example, then add coverage and ensure mypy reports the misplaced import as invalid syntax or an equivalent error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100