Skip to content

gh-131885: Clarify lazy import filters have positional-only parameters#144856

Open
johnslavik wants to merge 4 commits into
python:mainfrom
johnslavik:lazy-imports-filter-clarify-signature-positional
Open

gh-131885: Clarify lazy import filters have positional-only parameters#144856
johnslavik wants to merge 4 commits into
python:mainfrom
johnslavik:lazy-imports-filter-clarify-signature-positional

Conversation

@johnslavik

@johnslavik johnslavik commented Feb 15, 2026

Copy link
Copy Markdown
Member

Failing example:

import sys

sys.set_lazy_imports_filter(lambda *, importing_module, imported_module, fromlist: True)

lazy import foobar

📚 Documentation preview 📚: https://cpython-previews--144856.org.readthedocs.build/

@bedevere-app bedevere-app Bot added the docs Documentation in the Doc dir label Feb 15, 2026
@johnslavik johnslavik changed the title gh-131885: Clarify lazy import filters have positional-only arguments gh-131885: Clarify lazy import filters have positional-only parameters Feb 15, 2026
@github-project-automation github-project-automation Bot moved this to Todo in Docs PRs Feb 15, 2026
@johnslavik
johnslavik requested a review from AA-Turner February 15, 2026 23:56
Comment thread Doc/library/sys.rst Outdated
@bedevere-app

bedevere-app Bot commented Feb 15, 2026

Copy link
Copy Markdown

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@johnslavik

Copy link
Copy Markdown
Member Author

I have made the requested changes; please review again

@bedevere-app

bedevere-app Bot commented Feb 16, 2026

Copy link
Copy Markdown

Thanks for making the requested changes!

@AA-Turner: please review the changes made to this pull request.

@bedevere-app
bedevere-app Bot requested a review from AA-Turner February 16, 2026 00:07
@johnslavik

Copy link
Copy Markdown
Member Author

@AA-Turner :-)

@johnslavik

Copy link
Copy Markdown
Member Author

@AA-Turner

@johnslavik

Copy link
Copy Markdown
Member Author

@AA-Turner (If you can't look into this I'll appreciate if you just tell! Thanks!)

@github-actions

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label May 17, 2026
@johnslavik

Copy link
Copy Markdown
Member Author

@AA-Turner

@github-actions github-actions Bot removed the stale Stale PR or inactive for long period of time. label May 26, 2026
@johnslavik

Copy link
Copy Markdown
Member Author

@AA-Turner :-)

@johnslavik
johnslavik requested a review from encukou July 24, 2026 18:59
@johnslavik

Copy link
Copy Markdown
Member Author

I'm requesting a review from @encukou as Adam is unavailable.

@read-the-docs-community

Copy link
Copy Markdown

@encukou encukou left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Asking for review is asking for nitpicks, right?

Please click "update branch" or do git merge main (depending on your workflow) to get the tools the current CI needs.

Comment thread Doc/library/sys.rst

The filter function is called for every potentially lazy import to
determine whether it should actually be lazy. It must have the following
determine whether it should actually be lazy. It has the following

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It must accept 3 positional arguments. The exact signature is not a hard requirement.

Suggested change
determine whether it should actually be lazy. It has the following
determine whether it should actually be lazy. It should have the following

Comment thread Doc/library/sys.rst
def filter(importing_module: str, imported_module: str,
fromlist: tuple[str, ...] | None) -> bool

Where:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can put the info here, rather than in an extra paragraph:

Suggested change
The function is called with three positional arguments:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

4 participants