From 20170bebb158c7e102239c657d928f5284189beb Mon Sep 17 00:00:00 2001 From: bagel897 Date: Thu, 2 Nov 2023 18:54:28 -0500 Subject: [PATCH] ignore site-packages pt3 --- rope/contrib/autoimport/sqlite.py | 6 +++++- rope/contrib/autoimport/utils.py | 4 +--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/rope/contrib/autoimport/sqlite.py b/rope/contrib/autoimport/sqlite.py index aa576f3e1..4f58445f6 100644 --- a/rope/contrib/autoimport/sqlite.py +++ b/rope/contrib/autoimport/sqlite.py @@ -531,7 +531,11 @@ def _del_if_exist(self, module_name, commit: bool = True): def _get_python_folders(self) -> List[Path]: def filter_folders(folder: Path) -> bool: - return folder.is_dir() and folder.as_posix() != "/usr/bin" + return ( + folder.is_dir() + and folder.as_posix() != "/usr/bin" + and str(folder) != self.project.address + ) folders = self.project.get_python_path_folders() folder_paths = map(lambda folder: Path(folder.real_path), folders) diff --git a/rope/contrib/autoimport/utils.py b/rope/contrib/autoimport/utils.py index 5932f9bc2..22335fc27 100644 --- a/rope/contrib/autoimport/utils.py +++ b/rope/contrib/autoimport/utils.py @@ -22,8 +22,6 @@ def get_package_tuple( package_type: PackageType if package_name.startswith(".") or package_name == "__pycache__": return None - if "site-packages" in package_name: - return None if package_name.endswith((".egg-info", ".dist-info")): return None if package_path.is_file(): @@ -120,7 +118,7 @@ def get_files( yield ModuleFile(package.path, package.path.stem, underlined, False) else: assert package.path - for file in package.path.glob("**/*.py"): + for file in package.path.rglob("*.py"): if file.name == "__init__.py": yield ModuleFile( file,