Skip to content

Commit

Permalink
fix: Alternative fix, filter resource files
Browse files Browse the repository at this point in the history
  • Loading branch information
last-partizan committed Feb 25, 2024
1 parent edf2978 commit 36a28ad
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
5 changes: 4 additions & 1 deletion rope/contrib/autoimport/sqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,10 @@ def generate_cache(
project are cached.
"""
if resources is None:
resources = self.project.get_python_files()
resources = [
f for f in self.project.get_python_files()
if "site-packages" not in f.pathlib.parts
]
job_set = task_handle.create_jobset(
"Generating autoimport cache", len(resources)
)
Expand Down
1 change: 1 addition & 0 deletions rope/contrib/autoimport/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def get_modname_from_path(
modname = ""
try:
site_packages_index = rel_path_parts.index("site-packages")
raise RuntimeError("No site-packages allowed here.", modpath)
except ValueError:
pass
else:
Expand Down
7 changes: 7 additions & 0 deletions ropetest/contrib/autoimport/utilstest.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ def test_get_modname_single_file(typing_path):
assert utils.get_modname_from_path(typing_path, typing_path) == "typing"


def test_get_modname_external(example_external_package_path):
assert utils.get_modname_from_path(
example_external_package_path,
example_external_package_path,
) == "external_fixturepkg"


def test_get_modname_folder(
example_external_package_path,
example_external_package_module_path,
Expand Down

0 comments on commit 36a28ad

Please sign in to comment.