I'm wondering if for A, it should instead wrap a's annotation in a ForwardRef, so that users can then call evaluate() on it (e.g. with Format.VALUE) so that the exception from lazy_mod gets raised accordingly. Alternatively, the lazy import instance could be kept as is, but it would be great to document the resolve() method on types.LazyImportType.
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Good catch, I think we should solve this before 3.15 final. My preferred solution would be to wrap LazyImportType instances in a ForwardRef (as you suggest). That way, we'll need some special casing inside annotationlib, but LazyImportType objects won't escape to callers.
Activity
JelleZijlstra commented on Sep 4, 2026
Good catch, I think we should solve this before 3.15 final. My preferred solution would be to wrap LazyImportType instances in a ForwardRef (as you suggest). That way, we'll need some special casing inside annotationlib, but LazyImportType objects won't escape to callers.
94mbi7 commented on Sep 7, 2026
can i work on it if its still open
johnslavik commented on Sep 7, 2026
I'm surprised it wasn't documented.
gh-156924: Try reifying lazy imports in `ForwarRef.evaluate()` (#156940)
[3.15] gh-156924: Try reifying lazy imports in `ForwarRef.evaluate()` (…
Merge branch 'main' into tachyon-native-callable
pythongh-156924: Try reifying lazy imports in `ForwarRef.evaluate()` (p…
pythongh-156924: Try reifying lazy imports in `ForwarRef.evaluate()` (p…
[3.15] pythongh-156924: Try reifying lazy imports in `ForwarRef.evalu…