Skip to content

Commit 60f303c

Browse files
committed
Fix autoimport not scanning packages recursively
1 parent 35569ac commit 60f303c

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

rope/contrib/autoimport/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def get_files(
118118
yield ModuleFile(package.path, package.path.stem, underlined, False)
119119
else:
120120
assert package.path
121-
for file in package.path.glob("*.py"):
121+
for file in package.path.glob("**/*.py"):
122122
if file.name == "__init__.py":
123123
yield ModuleFile(
124124
file,

ropetest/contrib/autoimport/utilstest.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Tests for autoimport utility functions, written in pytest"""
22

3+
from pathlib import Path
4+
35
from rope.contrib.autoimport import utils
46
from rope.contrib.autoimport.defs import Package, PackageType, Source
57

@@ -57,3 +59,13 @@ def test_get_package_tuple_compiled(compiled_lib):
5759
assert Package(
5860
lib_name, Source.STANDARD, lib_path, PackageType.COMPILED
5961
) == utils.get_package_tuple(lib_path)
62+
63+
64+
def test_get_files(project, mod1, pkg1, mod2):
65+
root: Package = utils.get_package_tuple(project.root.pathlib)
66+
paths = [m.filepath.relative_to(project.root.pathlib) for m in utils.get_files(root)]
67+
assert paths == [
68+
Path("mod1.py"),
69+
Path("pkg1/__init__.py"),
70+
Path("pkg1/mod2.py"),
71+
]

0 commit comments

Comments
 (0)