Skip to content

Commit

Permalink
fix: Fix module name
Browse files Browse the repository at this point in the history
  • Loading branch information
last-partizan committed Feb 25, 2024
1 parent 323b03a commit edf2978
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 0 additions & 2 deletions rope/contrib/autoimport/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@ def get_type_object(imported_object) -> NameType:

def get_names(module: ModuleInfo, package: Package) -> List[Name]:
"""Get all names from a module and package."""
if "site-packages" in module.modname:
return []
if isinstance(module, ModuleCompiled):
return list(
get_names_from_compiled(package.name, package.source, module.underlined)
Expand Down
7 changes: 7 additions & 0 deletions rope/contrib/autoimport/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ def get_modname_from_path(
package_name: str = package_path.stem
rel_path_parts = modpath.relative_to(package_path).parts
modname = ""
try:
site_packages_index = rel_path_parts.index("site-packages")
except ValueError:
pass
else:
# If path includes "site-packages", we're interested in part after this.
rel_path_parts = rel_path_parts[site_packages_index + 1:]
if len(rel_path_parts) > 0:
for part in rel_path_parts[:-1]:
modname += part
Expand Down

0 comments on commit edf2978

Please sign in to comment.