Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PEP 690: Add flexibility to set_eager_imports() #2571

Merged
merged 4 commits into from
May 7, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions pep-0690.rst
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,17 @@ a list of module names within which all imports will be eager::
The effect of this is also shallow: all imports within ``one.mod`` will be
eager, but not imports in all modules imported by ``one.mod``.

``set_eager_imports()`` can also take a callback which receives a module name and returns
whether imports within this module should be eager::

import re
from importlib import set_eager_imports

def eager_imports(name):
return re.match(r"foo\.[^.]+\.logger", name)

set_eager_imports(eager_imports)


Backwards Compatibility
=======================
Expand Down