Skip to content

gh-130472: Use fancycompleter in import completions#148188

Merged
pablogsal merged 13 commits intopython:mainfrom
tomasr8:colorize-imports
May 5, 2026
Merged

gh-130472: Use fancycompleter in import completions#148188
pablogsal merged 13 commits intopython:mainfrom
tomasr8:colorize-imports

Conversation

@tomasr8
Copy link
Copy Markdown
Member

@tomasr8 tomasr8 commented Apr 6, 2026

image

Now that #130473 has been merged, let's use it for import completions as well.
This is my first stab at this. First, I did a bit of refactoring and extracted the getattr and colorize logic from FancyCompleter into reusable functions since I needed those for module completions. I also modified ModuleCompleter to return attribute values in addition to names (for modules, it just returns the sys module as a dummy value, this is just to get the color right). Then I just needed to extend get_module_completions to do the colorization.

@loic-simon would love if you have some spare time to have a look :)

tomasr8 added 7 commits April 6, 2026 22:30
- Make module completer return both names and values (dummy `sys` module
in case of module completions)
- Colorize completions using `colorize_matches` from FancyCompleter
Copy link
Copy Markdown
Contributor

@loic-simon loic-simon left a comment

Choose a reason for hiding this comment

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

Nice!! Here's a quick first pass, I'll play around with it in local later 😄

Comment thread Lib/_pyrepl/_module_completer.py Outdated
Comment thread Lib/_pyrepl/_module_completer.py Outdated
Comment thread Lib/_pyrepl/readline.py Outdated
Comment thread Lib/test/test_pyrepl/test_pyrepl.py
@loic-simon
Copy link
Copy Markdown
Contributor

Tested in local, all good for me! 🚀

@pablogsal
Copy link
Copy Markdown
Member

LGTM Great work @tomasr8 and thanks for the review @loic-simon. I have pushed a commit with some fixed and simplifications so it can make it to tomorrow's deadline!

@pablogsal pablogsal enabled auto-merge (squash) May 5, 2026 01:11
@pablogsal pablogsal disabled auto-merge May 5, 2026 01:11
@pablogsal pablogsal enabled auto-merge (squash) May 5, 2026 01:12
@read-the-docs-community
Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #32535593 | 📁 Comparing 0b29824 against main (2995d45)

  🔍 Preview build  

147 files changed · ± 145 modified · - 2 deleted

± Modified

- Deleted

@pablogsal pablogsal merged commit ed99680 into python:main May 5, 2026
65 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants