Skip to content

Support for lazy imports (PEP 810, Python 3.15+) #20978

@cjw296

Description

@cjw296

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 import and lazy from ... import statements
  • Treat lazy imports the same as regular imports for type checking purposes (as noted in PEP 810 § Typing and tools)

Related:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions