-
-
Notifications
You must be signed in to change notification settings - Fork 644
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle
from foo import *
wildcard imports in Rust dep inference par…
…ser (#19249) This fixes #19248 by implementing explicit handling for `*` wildcard imports in the Rust-based Python dependency inference parser. The commits are somewhat individually reviewable: 1. switching how the `insert_import` arguments are consumed from the syntax tree, for `from ... import ...` statements in particular: - before: `name` and `module_name` correspond to `import $name`, `"$name"`, `from $module_name import $name` - after: `base` and `imported` correspond to `import $base`, `"$base"`, `from $base import $imported` - This is in particular flipping the last one, and changes whether the `from ...` part is the optional arg (before) or not (after). - The motivation is that there's more functional similarities between the `from ...` part and a plain `import ...` statement, than between the `import ...` part and a plain `import ...` statement, despite the superficial similarities of it! (`from foo import bar` is a little like `import foo as __secret; bar = __secret.bar`.) 2. Add some tests that fail 3. Fix the bug 4. (and others) some tweaks, including defence-in-depth against similar problems happening in future
- Loading branch information
1 parent
ed3ddac
commit 8c95015
Showing
2 changed files
with
104 additions
and
28 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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