Skip to content

lazy import is not highlighted in the docs #153227

Description

@ZeroIntensity

Documentation

In our documentation, lazy in lazy import isn't highlighted as a keyword. This is because the latest version of Pygments, the highlighting library used by Sphinx, does not include the lazy import implementation.

Several weeks ago, I asked Pygments whether they were planning to release this anytime soon, but I haven't gotten a response. So, in the meantime, I think we should pin a development version of Pygments so the PEP 810 examples look correct.

cc @AA-Turner who I discussed this with on Discord a while back

Linked PRs

Activity

  1. added
    infraCI, GitHub Actions, buildbots, Dependabot, etc.
    on Jul 6, 2026
  2. added 2 commits that reference this issue on Jul 7, 2026
  3. ZeroIntensity commented on Jul 28, 2026

    @ZeroIntensity
    MemberAuthor

    Hmm, this didn't seem to apply to docs.python.org:

    Image

    Oddly, this did apply for PRs (see this RTD build, for example):

    Image

    Do we have a separate build configuration for the main site?

    cc @hugovk @StanFromIreland

  4. hugovk commented on Jul 28, 2026

    @hugovk
    Member

    I'm guessing it's because the docs server installs from requirements.txt and re-uses a per-version venv that isn't being upgraded. RTD uses both pylock.toml and a fresh build each run.

    A quick fix will be to delete the venv for 3.15 on the docs server.

    Perhaps we should update https://github.com/python/docsbuild-scripts to use pylock.toml (where available on newer branches) instead?

  5. hugovk commented on Jul 28, 2026

    @hugovk
    Member

    I opened python/docsbuild-scripts#345 to create a fresh venv each time, and also use pylock.toml when available.

  6. hugovk commented on Jul 30, 2026

    @hugovk
    Member

    That's merged and 3.16 docs have just rebuilt and we now have eager lazy highlighting!

    Image

    https://docs.python.org/3.16/whatsnew/3.15.html#whatsnew315-lazy-imports

  7. ZeroIntensity commented on Jul 30, 2026

    @ZeroIntensity
    MemberAuthor

    Thank you!

  8. added a commit that references this issue on Aug 21, 2026
  9. added a commit that references this issue on Sep 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dirinfraCI, GitHub Actions, buildbots, Dependabot, etc.topic-lazy-imports

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions