PEP 810 lazy_imports=all: imports in with-blocks are lazy, in try-blocks eager
Tested on CPython 3.15.2 and 3.16.0a1 (uv builds) with -X lazy_imports=all. An import inside try: stays eager, so the try: import fast_lib except ImportError: import fallback idiom still works (also the from-import form). An import inside a with block is lazy, so the module body runs at first use, after the context manager has exited. Two idioms break: (1) with warnings.catch_warnings(): warnings.simplefilter('ignore', DeprecationWarning); import noisy no longer silences the import-time warning; it is printed at the first noisy.X line, and under -W error::DeprecationWarning it raises there. (2) with contextlib.suppress(ImportError): import maybe_missing passes silently, then ModuleNotFoundError escapes at first use (eager mode gives NameError instead). Fix: touch the module inside the block (import noisy; noisy.X), or exempt it: sys.set_lazy_imports_filter(lambda imp, name, fl: name != "noisy") (tested). The explicit keyword follows the same split: lazy import json inside with is accepted, inside try it is 'SyntaxError: lazy import not allowed inside try/except blocks'. Imports inside function bodies were unaffected in my tests.