GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-130472: Integrate fancycompleter with the new repl, to get colored tab completions by antocuni · Pull Request #130473 · python/cpython

Conversation

@antocuni

@antocuni antocuni commented Feb 22, 2025 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

As the title says, this is (WIP) to integrate fancycompleter into the new REPL.

  • Issue: Use colors in tab-completion in PyREPL #130472

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bretello reacted with rocket emoji
All reactions
  • 🚀 1 reaction
@bedevere-app bedevere-app Bot mentioned this pull request Feb 22, 2025
Use colors in tab-completion in PyREPL #130472
Closed
hugovk
hugovk reviewed Feb 22, 2025
View reviewed changes

@hugovk hugovk left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Exciting! Just some nits.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Lib/_colorize.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/_colorize.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/_pyrepl/fancycompleter.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/_pyrepl/fancycompleter.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/_pyrepl/fancycompleter.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/_pyrepl/fancycompleter.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/_pyrepl/fancycompleter.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/test/test_pyrepl/test_fancycompleter.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/test/test_pyrepl/test_fancycompleter.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/_pyrepl/fancycompleter.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

tomasr8
tomasr8 reviewed Feb 22, 2025
View reviewed changes
Comment thread Lib/_pyrepl/fancycompleter.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/_pyrepl/fancycompleter.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/_pyrepl/fancycompleter.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/_pyrepl/fancycompleter.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/_pyrepl/readline.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/test/test_pyrepl/test_fancycompleter.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

AA-Turner
AA-Turner reviewed Feb 26, 2025
View reviewed changes
Comment thread Lib/_pyrepl/fancycompleter.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/_pyrepl/fancycompleter.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/_pyrepl/fancycompleter.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/_pyrepl/fancycompleter.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/_pyrepl/fancycompleter.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/_pyrepl/fancycompleter.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/_pyrepl/fancycompleter.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/_pyrepl/fancycompleter.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/_pyrepl/fancycompleter.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/_pyrepl/readline.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@antocuni

antocuni commented Sep 19, 2025

Copy link
Copy Markdown
Contributor Author

Assuming the tests are going to pass (last famous words), this is ready to review.
So far I have tested it only on my linux machine, if anybody has access to windows and macos it would be nice to do a "visual check" that things are going as intended.
This is how it looks like on my machine:

image

Compared to the initial version, I'm now using _colorize.get_theme() to get the colors.
I'm not 100% sure about _colorize.FancyCompleter though: for other use cases using a dataclass seems a good idea because the set of keys is known in advance, but here you potentially have an open ended set of types (ideally, users should be able to add their own types to the config).
So maybe we could turn the dataclass into a plain dict? This would also solve the ugly workaround to allow coloring method-wrapper here:
https://github.com/antocuni/cpython/blob/13a269807d24c4df0ec7bdca7b04369171c0db16/Lib/_pyrepl/fancycompleter.py#L153-L160

/cc @ambv as I think he's the one responsible for themes.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@antocuni
antocuni marked this pull request as ready for review September 19, 2025 14:15
@antocuni
antocuni requested review from ambv, lysnikolaou and pablogsal as code owners September 19, 2025 14:15
@bedevere-app bedevere-app Bot added the awaiting review label Sep 19, 2025
@antocuni

antocuni commented Sep 19, 2025

Copy link
Copy Markdown
Contributor Author

Also, I'm getting a warning from the doc builder but I'm not sure how to fix:


Warning: py:mod reference target not found: _pyrepl.fancycompleter [ref.mod]
/home/runner/work/cpython/cpython/Doc/using/cmdline.rst:1288: WARNING: py:mod reference target not found: _pyrepl.fancycompleter [ref.mod]

_pyrepl.fancycompleter is a module, do I need to add it somewhere else?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@antocuni antocuni mentioned this pull request Sep 19, 2025
Use pyrepl+fanycompleter as the default readline for pdb #139167
Open
@StanFromIreland

StanFromIreland commented Sep 19, 2025

Copy link
Copy Markdown
Member

_pyrepl.fancycompleter is a module, do I need to add it somewhere else?

Yes, but it is not documented. You can add an exclamation mark at the start to remove the link.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

StanFromIreland
StanFromIreland reviewed Sep 19, 2025
View reviewed changes
Comment thread Doc/using/cmdline.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

StanFromIreland
StanFromIreland reviewed Sep 19, 2025
View reviewed changes
Comment thread Doc/using/cmdline.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

eendebakpt
eendebakpt reviewed Sep 21, 2025
View reviewed changes
Comment thread Lib/_pyrepl/fancycompleter.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/_pyrepl/fancycompleter.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

hugovk
hugovk reviewed Sep 21, 2025
View reviewed changes
Comment thread Lib/_colorize.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@sstandre

sstandre commented Sep 26, 2025

Copy link
Copy Markdown
Contributor

So far I have tested it only on my linux machine, if anybody has access to windows and macos it would be nice to do a "visual check" that things are going as intended.

I tested it on Windows 10 using the Windows Terminal app.
This is using Powershell with Campbell theme:
image

antocuni reacted with hooray emoji
All reactions
  • 🎉 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

eendebakpt
eendebakpt reviewed Sep 26, 2025
View reviewed changes
Comment thread Lib/_pyrepl/fancycompleter.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

eendebakpt
eendebakpt reviewed Sep 26, 2025
View reviewed changes
Comment thread Lib/_pyrepl/fancycompleter.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

eendebakpt
eendebakpt reviewed Sep 26, 2025
View reviewed changes
Comment thread Lib/_pyrepl/fancycompleter.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

eendebakpt
eendebakpt reviewed Sep 26, 2025
View reviewed changes
Comment thread Lib/_pyrepl/fancycompleter.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

eendebakpt
eendebakpt reviewed Sep 26, 2025
View reviewed changes
Comment thread Lib/_pyrepl/fancycompleter.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

eendebakpt
eendebakpt reviewed Sep 26, 2025
View reviewed changes
Comment thread Lib/_pyrepl/fancycompleter.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

eendebakpt
eendebakpt reviewed Sep 27, 2025
View reviewed changes
Comment thread Lib/_pyrepl/fancycompleter.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

eendebakpt
eendebakpt reviewed Sep 27, 2025
View reviewed changes
Comment thread Lib/_pyrepl/fancycompleter.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

eendebakpt
eendebakpt reviewed Sep 27, 2025
View reviewed changes
Comment thread Lib/_pyrepl/fancycompleter.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

eendebakpt
eendebakpt reviewed Sep 27, 2025
View reviewed changes
Comment thread Lib/_pyrepl/fancycompleter.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

eendebakpt
eendebakpt reviewed Sep 27, 2025
View reviewed changes
Comment thread Lib/_pyrepl/fancycompleter.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@antocuni @pablogsal
import fancycompleter from pdbpp/fancycompleter@67e3ec1
d7eff96
antocuni and others added 15 commits April 5, 2026 14:25
@antocuni @pablogsal
fix mypy
ee882e7
@antocuni @pablogsal
document PYTHON_BASIC_COMPLETER
850d74b
@antocuni @pablogsal
try to manually fix the filename
7c603a2
@antocuni @StanFromIreland @pablogsal
Typo
cf6bf1e
Co-authored-by: Stan Ulbrych <[email protected]>
@antocuni @pablogsal
reword
0dc7d16
@antocuni @pablogsal
force PYTHON_COLORS=1 for tests which expects to see colors. Hopefull…
49eda06
…y this fixes the failures on Android CI
@antocuni @pablogsal
fix it in a different way: just look in the theme to find the expecte…
3ce8d00
…d color. This is both more robust and more correct
@antocuni @pablogsal
fix precommit
c71eed6
@antocuni @eendebakpt @pablogsal
Update Lib/_pyrepl/fancycompleter.py
d6b77e0
Co-authored-by: Pieter Eendebak <[email protected]>
@antocuni @pablogsal
put _colorize.FancyCompleter in alphabetical order w.r.t. the other s…
f919815
…ections
@antocuni @pablogsal
get_theme() is relatively expensive, fetch it early and cache it
97c684e
@antocuni @pablogsal
base is never used when calling commonprefix, remove it
588c204
@antocuni @eendebakpt @pablogsal
Update Lib/_pyrepl/fancycompleter.py
0646abb
Co-authored-by: Pieter Eendebak <[email protected]>
@antocuni @pablogsal
there is no need to sort words in advance, we can just sort names later
4b11774
@antocuni @pablogsal
undo 6a5bcfe: there IS actually a good reason to sort the words in ad…
9b9b37d
…vance, let's add a comment to explain why
@pablogsal
pablogsal force-pushed the antocuni/fancycompleter branch from 7d2c790 to 9b9b37d Compare April 5, 2026 13:27
@pablogsal
pythongh-130472: Fix pyrepl fancycompleter edge cases
cba06ba
Keep pyrepl completion logic working on the uncolored completion text.
The reader now strips ANSI escapes before comparing the typed stem,
inserting a sole completion, computing the shared prefix, and filtering
an open completion menu. This fixes colored completions that would stop
refining correctly once more characters were typed.

Restore readline's callable postfix behavior for attribute completions by
routing single attribute matches through rlcompleter's callable postfix
logic while keeping the full expr.attr stem for menu refinement. Global
completion also treats soft keywords as keywords instead of trying to
evaluate them.

Avoid side effects while probing attribute values for coloring by not
forcing property access and by preserving lazy module imports. Also make
the fake color-sorting escape prefix round-trip cleanly once the match
index grows past three digits.

Only honor PYTHON_BASIC_COMPLETER when the environment is enabled, so
pyrepl setup now respects -E / sys.flags.ignore_environment. Add
regression tests for the reader behavior, callable attribute completion,
property and lazy-import safety, large color-sort prefixes, and the -E
setup path.
@pablogsal

pablogsal commented Apr 5, 2026

Copy link
Copy Markdown
Member

Thanks for the great work on this, @antocuni . I rebased the branch and added a handful of follow-up fixes around the fancycompleter integration, including some edge cases and extra regression coverage.

This is in good shape now, and I’m planning to land it soon so it makes the next release.

antocuni reacted with heart emoji
All reactions
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

pablogsal
pablogsal approved these changes Apr 5, 2026
View reviewed changes

@pablogsal pablogsal left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM after my fixes

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting review labels Apr 5, 2026
@pablogsal
pablogsal enabled auto-merge (squash) April 5, 2026 13:58
@pablogsal
pablogsal merged commit 1c4408a into python:main Apr 5, 2026
64 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the awaiting merge label Apr 5, 2026
@tomasr8 tomasr8 mentioned this pull request Apr 5, 2026
PyREPL: auto-complete module attributes in import statements #140870
Closed
@StanFromIreland

StanFromIreland commented Apr 6, 2026

Copy link
Copy Markdown
Member

I think this has some issues...:

Screencast.From.2026-04-06.10-41-01.mp4
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

StanFromIreland
StanFromIreland reviewed Apr 6, 2026
View reviewed changes
Comment thread Lib/_pyrepl/fancycompleter.py
Comment on lines +187 to +189
# Encode the match index into a fake escape sequence that
# stripcolor() can still remove once i reaches four digits.
N = f"\x1b[{i // 100:03d};{i % 100:02d}m"

@StanFromIreland StanFromIreland Apr 6, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

These are in fact not always "fake," leading to the issues in my comment above. Fixing that (ensuring they are greater than 100, which IIRC is the limit of valid sequences), I still have contrast issues, so maybe there is more to it:

Image

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@pablogsal pablogsal Apr 6, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Let's open an issue and fix this in a separate PR

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@tomasr8 tomasr8 mentioned this pull request Apr 6, 2026
gh-130472: Use fancycompleter in import completions #148188
Merged
ljfp pushed a commit to ljfp/cpython that referenced this pull request Apr 25, 2026
@antocuni @pablogsal @ljfp
pythongh-130472: Integrate fancycompleter with the new repl, to get c…
11843e1
…olored tab completions (python#130473)

Co-authored-by: Pablo Galindo <[email protected]>
@bretello bretello mentioned this pull request Nov 8, 2026
python 3.15 support bretello/pdbpp#93
Draft
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@eendebakpt eendebakpt eendebakpt left review comments
@hugovk hugovk hugovk left review comments
@tomasr8 tomasr8 tomasr8 left review comments
@AA-Turner AA-Turner AA-Turner left review comments
@pablogsal pablogsal pablogsal approved these changes
@StanFromIreland StanFromIreland StanFromIreland left review comments
@lysnikolaou lysnikolaou Awaiting requested review from lysnikolaou lysnikolaou is a code owner
@ambv ambv Awaiting requested review from ambv ambv is a code owner
+2 more reviewers
@theY4Kman theY4Kman theY4Kman left review comments
@slinkp slinkp slinkp left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

10 participants

@antocuni @StanFromIreland @sstandre @pablogsal @theY4Kman @slinkp @eendebakpt @hugovk @tomasr8 @AA-Turner
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.