diff --git a/astroid/manager.py b/astroid/manager.py index fc30bf9e2f..22ceec3c29 100644 --- a/astroid/manager.py +++ b/astroid/manager.py @@ -23,6 +23,7 @@ from astroid.modutils import ( NoSourceFile, _cache_normalize_path_, + _has_init, file_info_from_modpath, get_source_file, is_module_name_part_of_extension_package_whitelist, @@ -457,6 +458,7 @@ def clear_cache(self) -> None: for lru_cache in ( LookupMixIn.lookup, _cache_normalize_path_, + _has_init, util.is_namespace, ObjectModel.attributes, ClassDef._metaclass_lookup_attribute, diff --git a/astroid/modutils.py b/astroid/modutils.py index 6f67d1ab9a..971e1b7297 100644 --- a/astroid/modutils.py +++ b/astroid/modutils.py @@ -666,6 +666,7 @@ def _is_python_file(filename: str) -> bool: return filename.endswith((".py", ".pyi", ".so", ".pyd", ".pyw")) +@lru_cache(maxsize=1024) def _has_init(directory: str) -> str | None: """If the given directory has a valid __init__ file, return its path, else return None.