Skip to content

Commit

Permalink
Merge pull request #688 from python-rope/lieryan-missing-symbols
Browse files Browse the repository at this point in the history
Fix autoimport not scanning packages recursively
  • Loading branch information
lieryan committed Apr 18, 2023
2 parents 35569ac + 6d73e72 commit b9580da
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- #650 Install pre-commit hooks on rope repository (@lieryan)
- #655 Remove unused __init__() methods (@edreamleo, @lieryan)
- #674 Fix/supress all mypy complaints
- #687 Fix autoimport not scanning packages recursively (@lieryan)


# Release 1.7.0
Expand Down
2 changes: 1 addition & 1 deletion rope/contrib/autoimport/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,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.glob("**/*.py"):
if file.name == "__init__.py":
yield ModuleFile(
file,
Expand Down
12 changes: 12 additions & 0 deletions ropetest/contrib/autoimport/utilstest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Tests for autoimport utility functions, written in pytest"""

from pathlib import Path

from rope.contrib.autoimport import utils
from rope.contrib.autoimport.defs import Package, PackageType, Source

Expand Down Expand Up @@ -57,3 +59,13 @@ def test_get_package_tuple_compiled(compiled_lib):
assert Package(
lib_name, Source.STANDARD, lib_path, PackageType.COMPILED
) == utils.get_package_tuple(lib_path)


def test_get_files(project, mod1, pkg1, mod2):
root: Package = utils.get_package_tuple(project.root.pathlib)
paths = [m.filepath.relative_to(project.root.pathlib) for m in utils.get_files(root)]
assert set(paths) == {
Path("mod1.py"),
Path("pkg1/__init__.py"),
Path("pkg1/mod2.py"),
}

0 comments on commit b9580da

Please sign in to comment.