Skip to content

set_lazy_imports_filter's first arg (importing_module) can be None#15901

Merged
srittau merged 1 commit into
mainfrom
Avasam-patch-1
Jun 12, 2026
Merged

set_lazy_imports_filter's first arg (importing_module) can be None#15901
srittau merged 1 commit into
mainfrom
Avasam-patch-1

Conversation

@Avasam

@Avasam Avasam commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

In real world scenario (see Toufool/AutoSplit@ba2e3d4#diff-37d213d547553f3e9f803b055881175eebb3b15caf26baec90775d81be0389f0 where I was playing around with the new lazy import filtering API) I've hit the first arg being None. I think from exec'd/embedded code (e.g. shiboken6's signature bootstrap)

Weirdly, this is not documented: https://docs.python.org/3.15/library/sys.html#sys.set_lazy_imports_filter
I've considered | MaybeNone, but this is already advanced usage, may as well be correct and let advanced users account for this edge case.

@Avasam Avasam requested a review from JelleZijlstra June 12, 2026 18:04
@github-actions

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@srittau srittau left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It's definitely safer if user code handles this edge case.

@srittau srittau merged commit d25e1e7 into main Jun 12, 2026
58 checks passed
@srittau srittau deleted the Avasam-patch-1 branch June 12, 2026 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants