Skip to content

Commit 5c46116

Browse files
committed
fixup! Update pep-0810.rst
1 parent 29332ff commit 5c46116

1 file changed

Lines changed: 0 additions & 37 deletions

File tree

peps/pep-0810.rst

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,36 +1233,6 @@ Can I force reification of a lazy import without using it?
12331233
Yes, individual lazy objects can be resolved by calling their ``resolve()``
12341234
method.
12351235

1236-
What's the difference between ``globals()`` and ``mod.__dict__`` for lazy imports?
1237-
----------------------------------------------------------------------------------
1238-
1239-
Both ``globals()`` and ``mod.__dict__`` return the module's dictionary without
1240-
reifying lazy imports. Accessing lazy objects through either will yield lazy
1241-
proxy objects. This provides a consistent low-level API for introspection:
1242-
1243-
.. code-block:: python
1244-
1245-
# In your module:
1246-
lazy import json
1247-
1248-
g = globals()
1249-
print(type(g['json'])) # <class 'LazyImport'>
1250-
1251-
d = __dict__
1252-
print(type(d['json'])) # <class 'LazyImport'>
1253-
1254-
# From external code:
1255-
import sys
1256-
mod = sys.modules['your_module']
1257-
d = mod.__dict__
1258-
print(type(d['json'])) # <class 'LazyImport'>
1259-
1260-
Both ``globals()`` and ``__dict__`` expose the raw namespace view without
1261-
implicit side effects. This symmetry makes the behavior predictable: accessing
1262-
the namespace dictionary never triggers imports. If you need to ensure an
1263-
import is resolved, call the ``resolve()`` method explicitly or access the
1264-
attribute directly (e.g., ``json.dumps``).
1265-
12661236
Why not use ``importlib.util.LazyLoader`` instead?
12671237
--------------------------------------------------
12681238

@@ -1665,13 +1635,6 @@ cases like ``with suppress(ImportError): lazy import foo``, static analysis
16651635
tools and linters are better suited to catch these patterns than hard language
16661636
restrictions.
16671637

1668-
Additionally, forbidding explicit ``lazy import`` in ``with`` blocks would
1669-
create complex rules for how the global lazy imports flag should behave,
1670-
leading to confusing inconsistencies between explicit and implicit laziness. By
1671-
allowing ``lazy import`` in ``with`` blocks, the rule is simple: the global
1672-
flag affects all module-level imports except those in ``try`` blocks and wild
1673-
card imports, matching exactly what's allowed with explicit syntax.
1674-
16751638
Forcing eager imports in ``with`` blocks under the global flag
16761639
---------------------------------------------------------------
16771640

0 commit comments

Comments
 (0)