Skip to content

Conversation

@asukaminato0721
Copy link
Contributor

Summary

part of #2207

Added auto-import suggestions for submodules so completions insert from <parent> import <submodule> (and corresponding quickfix entries).

Test Plan

Added a new LSP completion test and fixtures.

@meta-cla meta-cla bot added the cla signed label Feb 5, 2026
@asukaminato0721 asukaminato0721 marked this pull request as ready for review February 5, 2026 15:04
Copilot AI review requested due to automatic review settings February 5, 2026 15:04
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements auto-import suggestions for submodules as part of issue #2207. When a user types a submodule name that's not imported, the IDE will now suggest adding from <parent_module> import <submodule> imports, both in completions and as quick-fix code actions.

Changes:

  • Added auto-import completion support for submodules that generates from parent import submodule style imports
  • Added corresponding code action (quick-fix) suggestions for importing submodules
  • Added comprehensive test coverage with new test fixtures and test case

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
pyrefly/lib/test/lsp/lsp_interaction/test_files/autoimport_submodule/pyrefly.toml Test configuration file defining search path
pyrefly/lib/test/lsp/lsp_interaction/test_files/autoimport_submodule/foo.py Test file with copyright header (content added dynamically in test)
pyrefly/lib/test/lsp/lsp_interaction/test_files/autoimport_submodule/autoimport_submodule_pkg/auto_submodule.py Test submodule containing a VALUE constant for testing
pyrefly/lib/test/lsp/lsp_interaction/test_files/autoimport_submodule/autoimport_submodule_pkg/init.py Package initialization file for test package
pyrefly/lib/test/lsp/lsp_interaction/completion.rs New test case validating submodule auto-import completions
pyrefly/lib/state/lsp.rs Added code action logic to suggest submodule imports in quick-fix suggestions
pyrefly/lib/lsp/wasm/completion.rs Added completion item logic to suggest submodule imports in auto-completion

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link

github-actions bot commented Feb 5, 2026

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants