Fall back to module bindings for star-import suggestions when __all__ is partly dynamic - #365
Merged
Merged
Conversation
… is partly dynamic With `__all__ = list(core.__all__)` followed by `__all__ += ["beta"]`, only the literal part was known, and because it was not empty the fallback to the module's bindings was skipped. Rewriting `from lib import *` then dropped names that are used. Any non-literal __all__ assignment, item or method call now marks it dynamic, and the module's bindings are suggested as well. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019P9bvuGwAyVCNUdsAYPB1V
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Regression from #345 (
__all__ +=support), found in the second review ofclaude/integration.Problem
Only
betawas read from__all__. Because that list was not empty, the fallback to the module's bindings was skipped, and--include-star-importrewrote the import tofrom lib import beta, which raisesNameErroronalpha.mainsuggestedalpha, beta.Fix
ImportableNameAnalyzer.is_dynamicis set when any__all__assignment, augmented assignment (non-+), item,append/extendargument or other method call can't be read statically. In that caseiget_importable_nameyields the literal names and the module's bindings.extendnow also accepts tuples and sets, through the shared_add_items.Tests
test_star_import_suggestions_with_partly_dynamic_allfails before this change. Full suite passes on 3.9 / 3.12 / 3.14, and pre-commit passes.🤖 Generated with Claude Code
https://claude.ai/code/session_019P9bvuGwAyVCNUdsAYPB1V
Generated by Claude Code