FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-130472: Integrate fancycompleter with the new repl, to get colored tab completions by antocuni · Pull Request #130473 · python/cpython · GitHub

Repository navigation

Merged
Changes from 1 commit
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
d7eff96
import fancycompleter from https://github.com/pdbpp/fancycompleter/co…
antocuni Feb 18, 2025
e22a210
add copyright notice
antocuni Feb 18, 2025
374eff9
enable FancyCompleter by default, unless you set PYTHON_BASIC_COMPLETER
antocuni Feb 18, 2025
9eeca3a
WIP: kill a lot of code which is no longer necessary
antocuni Feb 18, 2025
1c5d27d
force colors for now
antocuni Feb 18, 2025
c621cf5
kill the logic to find a readline, we can always use _pyrepl.readline…
antocuni Feb 18, 2025
d839aa1
kill LazyVersion
antocuni Feb 18, 2025
f89b9ef
we surely don't need to support python 2.7 now :)
antocuni Feb 18, 2025
04b5fee
kill ConfigurableClass
antocuni Feb 18, 2025
d733675
better name
antocuni Feb 18, 2025
116a634
use _colorize instead of our own Color
antocuni Feb 18, 2025
98d3f86
WIP: copy&adapt some tests from the original fancycompleter. They don…
antocuni Feb 18, 2025
9d40f1b
edited by copilot: move from pytest-style to unittest-style
antocuni Feb 18, 2025
d04f41d
don't try to be too clever with exceptions: if a global name raises a…
antocuni Feb 18, 2025
15ea5de
no longer needed
antocuni Feb 18, 2025
0063a70
this doesn't test anything meaningful
antocuni Feb 18, 2025
0af3c84
fix this test
antocuni Feb 18, 2025
d9a9f6f
fix this test
antocuni Feb 18, 2025
0c26812
Fix this test
antocuni Feb 18, 2025
30468ac
Apply hugovk suggestions from code review
antocuni Sep 19, 2025
4700d1a
Apply suggestions from code review
antocuni Sep 19, 2025
26591ae
Apply suggestions from code review
antocuni Sep 19, 2025
b2414f8
remove unneeded lazy import
antocuni Sep 19, 2025
24e4afb
Update Lib/_pyrepl/fancycompleter.py
antocuni Sep 19, 2025
b5935bc
move import to module scope
antocuni Sep 19, 2025
0fbdabc
move import
antocuni Sep 19, 2025
06840b0
kill this for now, we can redintroduce it later if/when we enable fan…
antocuni Sep 19, 2025
56384ee
this link is dead, add a comment to explain what it does instead
antocuni Sep 19, 2025
49f90f5
fix precommit
antocuni Sep 19, 2025
3c441e1
we need to make this import lazy, else we get circular imports
antocuni Sep 19, 2025
aabf91c
now that we have themes, we can kill the config object
antocuni Sep 19, 2025
233c51d
style
antocuni Sep 19, 2025
1a86caf
📜🤖 Added by blurb_it.
blurb-it[bot] Sep 19, 2025
ee882e7
fix mypy
antocuni Sep 19, 2025
850d74b
document PYTHON_BASIC_COMPLETER
antocuni Sep 19, 2025
7c603a2
try to manually fix the filename
antocuni Sep 19, 2025
cf6bf1e
Typo
antocuni Sep 19, 2025
0dc7d16
reword
antocuni Sep 19, 2025
49eda06
force PYTHON_COLORS=1 for tests which expects to see colors. Hopefull…
antocuni Sep 19, 2025
3ce8d00
fix it in a different way: just look in the theme to find the expecte…
antocuni Sep 19, 2025
c71eed6
fix precommit
antocuni Sep 19, 2025
d6b77e0
Update Lib/_pyrepl/fancycompleter.py
antocuni Sep 21, 2025
f919815
put _colorize.FancyCompleter in alphabetical order w.r.t. the other s…
antocuni Sep 22, 2025
97c684e
get_theme() is relatively expensive, fetch it early and cache it
antocuni Sep 26, 2025
588c204
base is never used when calling commonprefix, remove it
antocuni Sep 26, 2025
0646abb
Update Lib/_pyrepl/fancycompleter.py
antocuni Sep 26, 2025
4b11774
there is no need to sort words in advance, we can just sort names later
antocuni Sep 27, 2025
9b9b37d
undo 6a5bcfe9ed: there IS actually a good reason to sort the words in…
antocuni Sep 27, 2025
cba06ba
gh-130472: Fix pyrepl fancycompleter edge cases
pablogsal Apr 5, 2026
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
Prev Previous commit
Next Next commit
fix it in a different way: just look in the theme to find the expecte…
…d color. This is both more robust and more correct
  • Loading branch information
antocuni authored and pablogsal committed Apr 5, 2026
commit 3ce8d006333f1fb070ab6011985cb2ae3224ef2d
21 changes: 4 additions & 17 deletions Lib/test/test_pyrepl/test_fancycompleter.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import unittest
import os
from unittest.mock import patch

from _colorize import ANSIColors, get_theme
from _pyrepl.fancycompleter import Completer, commonprefix
Expand Down Expand Up @@ -59,7 +58,6 @@ class C(object):
compl = Completer({'a': None}, use_colors=False)
self.assertEqual(compl.attr_matches('a._'), ['a.__'])

@patch.dict(os.environ, {'PYTHON_COLORS': '1'})
def test_complete_attribute_colored(self):
theme = get_theme()
compl = Completer({'a': 42}, use_colors=True)
Expand Down Expand Up @@ -96,8 +94,8 @@ def test_complete_global(self):
self.assertEqual(compl.global_matches('foobaz'), ['foobazzz'])
self.assertEqual(compl.global_matches('nothing'), [])

@patch.dict(os.environ, {'PYTHON_COLORS': '1'})
def test_complete_global_colored(self):
theme = get_theme()
compl = Completer({'foobar': 1, 'foobazzz': 2}, use_colors=True)
self.assertEqual(compl.global_matches('foo'), ['fooba'])
matches = compl.global_matches('fooba')
Expand All @@ -106,26 +104,15 @@ def test_complete_global_colored(self):
# readline displays the matches in the proper order
N0 = f"\x1b[000;00m"
N1 = f"\x1b[001;00m"

int_color = theme.fancycompleter.int
self.assertEqual(set(matches), {
' ',
f'{N0}{ANSIColors.BOLD_YELLOW}foobar{ANSIColors.RESET}',
f'{N1}{ANSIColors.BOLD_YELLOW}foobazzz{ANSIColors.RESET}',
f'{N0}{int_color}foobar{ANSIColors.RESET}',
f'{N1}{int_color}foobazzz{ANSIColors.RESET}',
})
self.assertEqual(compl.global_matches('foobaz'), ['foobazzz'])
self.assertEqual(compl.global_matches('nothing'), [])

@patch.dict(os.environ, {'PYTHON_COLORS': '1'})
def test_complete_global_colored_exception(self):
compl = Completer({'tryme': 42}, use_colors=True)
N0 = f"\x1b[000;00m"
N1 = f"\x1b[001;00m"
self.assertEqual(compl.global_matches('try'), [
f'{N0}{ANSIColors.GREY}try:{ANSIColors.RESET}',
f'{N1}{ANSIColors.BOLD_YELLOW}tryme{ANSIColors.RESET}',
' '
])

def test_complete_with_indexer(self):
compl = Completer({'lst': [None, 2, 3]}, use_colors=False)
self.assertEqual(compl.attr_matches('lst[0].'), ['lst[0].__'])
Expand Down

Back | FazBrowse Home | New Git URL