ruff
4ddf9228 - Bind top-most parent when importing nested module (#14946)

Commit
291 days ago
Bind top-most parent when importing nested module (#14946) When importing a nested module, we were correctly creating a binding for the top-most parent, but we were binding that to the nested module, not to that parent module. Moreover, we weren't treating those submodules as members of their containing parents. This PR addresses both issues, so that nested imports work as expected. As discussed in ~Slack~ whatever chat app I find myself in these days :smile:, this requires keeping track of which modules have been imported within the current file, so that when we resolve member access on a module reference, we can see if that member has been imported as a submodule. If so, we return the submodule reference immediately, instead of checking whether the parent module's definition defines the symbol. This is currently done in a flow insensitive manner. The `SemanticIndex` now tracks all of the modules that are imported (via `import`, not via `from...import`). The member access logic mentioned above currently only considers module imports in the file containing the attribute expression. --------- Co-authored-by: Carl Meyer <carl@astral.sh>
Author
Parents
Loading