Skip to content

gh-130472: Use fancycompleter in import completions - #148188

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

pablogsal merged 13 commits into
python:mainfrom
tomasr8:colorize-imports

Conversation

@tomasr8

@tomasr8 tomasr8 commented Apr 6, 2026 •

Copy link
Copy Markdown
Member
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

@loic-simon loic-simon left a comment

Copy link
Copy Markdown
Contributor

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 Resolved
Comment thread Lib/_pyrepl/_module_completer.py Resolved
Comment thread Lib/_pyrepl/readline.py Resolved
Comment thread Lib/test/test_pyrepl/test_pyrepl.py Resolved
@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
@pablogsal
pablogsal merged commit ed99680 into python:main May 5, 2026
61 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants