Support for `lazy` imports (PEP 810, Python 3.15+)
Open
Nobody has claimed this yet.
feature
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
Python 3.15 introduces PEP 810 - Explicit lazy imports via the new lazy soft keyword:
lazy import json
lazy from pathlib import Path
Currently mypy reports these as syntax errors. Support is needed to:
- Update the parser to recognise
lazy importandlazy from ... importstatements - Treat lazy imports the same as regular imports for type checking purposes (as noted in PEP 810 § Typing and tools)
Related:
- astral-sh/ruff#21305 (ruff tracking issue)
- astral-sh/ty#2968 (ty tracking issue)
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 tracing the parser support for lazy import and lazy from ... import statements, then follow the type-checking path for regular imports. Use PEP 810's “Typing and tools” section as the behavioral reference. Done means both forms are accepted and treated like regular imports for type checking without syntax errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100