mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
[3.14] gh-134235: Import Autocomplete for Builtin Modules (GH-134277) (#134285)
gh-134235: Import Autocomplete for Builtin Modules (GH-134277)
* added enhancement auto completing import with sys builtins
---------
(cherry picked from commit 8421b03b16)
Co-authored-by: Tom Wang <85062819+tommix626@users.noreply.github.com>
Co-authored-by: Hunter <hyoung3@gmail.com>
This commit is contained in:
parent
7686c752b3
commit
7cbc3ea8fb
3 changed files with 25 additions and 2 deletions
|
|
@ -81,8 +81,9 @@ def find_modules(self, path: str, prefix: str) -> list[str]:
|
|||
def _find_modules(self, path: str, prefix: str) -> list[str]:
|
||||
if not path:
|
||||
# Top-level import (e.g. `import foo<tab>`` or `from foo<tab>`)`
|
||||
return [name for _, name, _ in self.global_cache
|
||||
if name.startswith(prefix)]
|
||||
builtin_modules = [name for name in sys.builtin_module_names if name.startswith(prefix)]
|
||||
third_party_modules = [name for _, name, _ in self.global_cache if name.startswith(prefix)]
|
||||
return sorted(builtin_modules + third_party_modules)
|
||||
|
||||
if path.startswith('.'):
|
||||
# Convert relative path to absolute path
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue