MCPcopy Index your code
hub / github.com/python/cpython / _is_lazy_import

Function _is_lazy_import

Lib/traceback.py:1661–1674  ·  view source on GitHub ↗

Check if attr_name in obj's __dict__ is a lazy import. Returns True if obj is a module and the attribute is a LazyImportType, False otherwise. This avoids triggering module loading when computing suggestions for AttributeError.

(obj, attr_name)

Source from the content-addressed store, hash-verified

1659
1660
1661def _is_lazy_import(obj, attr_name):
1662 """Check if attr_name in obj's __dict__ is a lazy import.
1663
1664 Returns True if obj is a module and the attribute is a LazyImportType,
1665 False otherwise. This avoids triggering module loading when computing
1666 suggestions for AttributeError.
1667 """
1668 if not isinstance(obj, types.ModuleType):
1669 return False
1670 obj_dict = getattr(obj, '__dict__', None)
1671 if obj_dict is None:
1672 return False
1673 attr_value = obj_dict.get(attr_name)
1674 return isinstance(attr_value, types.LazyImportType)
1675
1676
1677def _check_for_nested_attribute(obj, wrong_name, attrs):

Callers 2

_get_safe___dir__Function · 0.85

Calls 1

getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…