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)
| 1659 | |
| 1660 | |
| 1661 | def _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 | |
| 1677 | def _check_for_nested_attribute(obj, wrong_name, attrs): |
no test coverage detected
searching dependent graphs…