PyCQA / PyCQA/isort

Support explicit lazy imports in Python 3.15 (PEP 810)

Open
#2,462 4 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement help wanted
Dominant language
Python
Stars
7k
Forks
687
Avg merge
4h 56m
Merged PRs (30d)
2

Description

PEP 810 "Explicit lazy imports" has been accepted and is coming to Python 3.15 (2026-03-10's 3.15.0a7 will be the first release).

This adds a new lazy keyword for imports:

lazy import json
lazy from json import dumps

And also a __lazy_modules__ for backwards compatibility with pre-3.15:

__lazy_modules__ = ["json"]
import json

It would be useful to also sort __lazy_modules__. Two options:

  • Alphabetical
  • Follow the isort settings, for example: stdlib, third-party, local

The Steering Council's acceptance said:

We agree that the PEP should take no position on any style recommendations for sorting lazy imports. While we generally like the idea of grouping lazy imports together, let’s leave that up to the linters and auto-formatters to decide the details.

See also https://github.com/astral-sh/ruff/issues/21305.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with PEP 810 and the existing isort settings that control import grouping and ordering. Determine how explicit lazy imports and the lazy_modules compatibility form should be recognized and sorted, then verify that the chosen ordering is consistent with the project's import-sorting behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.