Skip to content

Commit 24f168c

Browse files
committed
Add the override-global-flag filter to the list of rejected ideas, with
rationale.
1 parent 4113b86 commit 24f168c

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

peps/pep-0810.rst

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,6 +1406,31 @@ confusion about what the default is, or when the ``eager`` keyword would be
14061406
necessary, or whether it affects lazy imports *in* the explicitly eagerly
14071407
imported module.
14081408

1409+
Allowing the filter to force lazy imports even when globally disabled
1410+
---------------------------------------------------------------------
1411+
1412+
As lazy imports allow some forms of circular imports that would otherwise
1413+
fail, as an intentional and desireable thing (especially for typing-related
1414+
imports), the suggestion was made to add a way to override the global
1415+
disable, like allowing the lazy imports filter to override the global
1416+
disable the way it can override a global enable. The risk here is that we
1417+
end up in a confusing situation where some things are overridden and others
1418+
are not depending on the relevant priority as we perceive them now, and that
1419+
we'll need new ways to disable or enable as the use of lazy imports evolves.
1420+
The global disable is not expected to see commonplace use, but be more of a
1421+
debugging and selective testing tool for those who want to tightly control
1422+
their dependency on lazy imports. We don't think it's unreasonable as
1423+
packages to adopt lazy imports for them to decide to not work with lazy
1424+
imports globally disabled, if that's what they want.
1425+
1426+
It may be that this means that in time, as more and more packages embrace
1427+
both typing and lazy imports, the global disable becomes mostly unused and
1428+
unusable. Similar things have happened in the past with other global flags,
1429+
and given the low cost of the flag this seems acceptable. It's also a easier
1430+
to add more specific re-enabling mechanisms later, when we have a clearer
1431+
picture of real-world use and patterns, than it is to remove a hastily added
1432+
mechanism that isn't quite right.
1433+
14091434
Using a context manager instead of a new soft keyword
14101435
-----------------------------------------------------
14111436

0 commit comments

Comments
 (0)