Skip to content

fix(python): don't treat obj.import_module() as a dynamic import - #825

Merged
rowkav09 merged 2 commits into
mainfrom
fix-dynamic-method
Oct 3, 2026
Merged

rowkav09 merged 2 commits into
mainfrom
fix-dynamic-method

Conversation

@rowkav09

@rowkav09 rowkav09 commented Oct 3, 2026

Copy link
Copy Markdown
Member

Fixes #823.

The dynamic-import pattern could start after a dot or inside a longer name, so obj.import_module("requests"), obj.__import__("numpy") and myimportlib.import_module("scipy") were reported as real dynamic imports. It now requires that the call is not preceded by a dot or an identifier character. The real receivers are still accepted: importlib.import_module, bare import_module, and __import__ bare or via importlib / builtins / __builtins__.

Tests: the negative cases fail without the change; positives cover the receivers above, including spaces around the dot. Adapter suite passes (257).

Aliased importlib / import_module are a separate, older gap: #824.

Require the call name not to follow a dot or an identifier character. Fixes #823.
Allow importlib as a receiver for __import__, as before the receiver check.
@rowkav09
rowkav09 merged commit 94aab13 into main Oct 3, 2026
14 checks passed
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.

Python: obj.import_module(...) and similar are reported as dynamic imports

1 participant