Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Simpler approach
  • Loading branch information
JelleZijlstra committed Apr 4, 2025
commit 651785bc02c23e9d230bdd34e22ceda06d3a112c
15 changes: 4 additions & 11 deletions Lib/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,18 +162,11 @@
]

class _LazyAnnotationLib:
def __init__(self) -> None:
self._annolib = None

def __getattr__(self, attr):
if self._annolib is None:
import annotationlib

self._annolib = annotationlib

value = getattr(self._annolib, attr)
setattr(self, attr, value)
return value
global _lazy_annotationlib
import annotationlib
_lazy_annotationlib = annotationlib
return getattr(annotationlib, attr)

_lazy_annotationlib = _LazyAnnotationLib()
Comment thread
AlexWaygood marked this conversation as resolved.

Expand Down