Skip to content

Fix subpackage import incorrectly removed when sibling subpackage is used (#180)#322

Merged
hakancelikdev merged 4 commits intomainfrom
fix/subpackage-import-attribute-usage
Feb 18, 2026
Merged

Fix subpackage import incorrectly removed when sibling subpackage is used (#180)#322
hakancelikdev merged 4 commits intomainfrom
fix/subpackage-import-attribute-usage

Conversation

@hakancelikdev
Copy link
Copy Markdown
Owner

import a.b binds a in the namespace, so any a.x.y reference relies on that binding. is_match_sub_packages was comparing the import's root package against the full name string instead of just its first component, causing attribute usages like urllib.parse.urlparse to not match import urllib.request.

…used (#180)

`import a.b` binds `a` in the namespace, so any `a.x.y` reference
relies on that binding. `is_match_sub_packages` was comparing the
import's root package against the full name string instead of just
its first component, causing attribute usages like `urllib.parse.urlparse`
to not match `import urllib.request`.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
hakancelikdev and others added 3 commits February 18, 2026 10:40
When multiple imports share the same root package (e.g. import urllib.request
and import urllib.parse), is_match_sub_packages was matching both to any
urllib.* name usage, causing false negatives. Added _has_more_specific_import
to check if another import provides a more direct path match for the name,
so the sub-package fallback only applies when no specific import exists.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@hakancelikdev hakancelikdev merged commit 1b8b089 into main Feb 18, 2026
35 checks passed
@hakancelikdev hakancelikdev deleted the fix/subpackage-import-attribute-usage branch February 18, 2026 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use of implicitly imported module namespace not considered correctly

1 participant