Skip to content

Commit 1de48b6

Browse files
antocunihugovk
andauthored
Apply hugovk suggestions from code review
Co-authored-by: Hugo van Kemenade <[email protected]>
1 parent c61bab6 commit 1de48b6

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

Lib/_colorize.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@
88
class ANSIColors:
99
BACKGROUND_YELLOW = "\x1b[43m"
1010
BOLD_BLUE = "\x1b[1;34m"
11+
BOLD_CYAN = "\x1b[1;36m"
1112
BOLD_GREEN = "\x1b[1;32m"
1213
BOLD_MAGENTA = "\x1b[1;35m"
1314
BOLD_RED = "\x1b[1;31m"
14-
BOLD_TEAL = "\x1b[1;36m"
1515
BOLD_YELLOW = "\x1b[1;33m"
1616
BLACK = "\x1b[30m"
17+
CYAN = "\x1b[36m"
1718
GREEN = "\x1b[32m"
1819
GREY = "\x1b[90m"
1920
MAGENTA = "\x1b[35m"
2021
RED = "\x1b[31m"
2122
RESET = "\x1b[0m"
22-
TEAL = "\x1b[36m"
2323
YELLOW = "\x1b[33m"
2424

2525

Lib/_pyrepl/fancycompleter.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
# All Rights Reserved
55
"""
6-
Colorful TAB completion for Python prompt
6+
Colorful tab completion for Python prompt
77
"""
88
from _pyrepl import readline
99
from _colorize import ANSIColors
@@ -18,18 +18,18 @@ class DefaultConfig:
1818
use_colors = 'auto'
1919

2020
color_by_type = {
21-
types.BuiltinMethodType: ANSIColors.BOLD_TEAL,
22-
types.MethodType: ANSIColors.BOLD_TEAL,
23-
type((42).__add__): ANSIColors.BOLD_TEAL,
24-
type(int.__add__): ANSIColors.BOLD_TEAL,
25-
type(str.replace): ANSIColors.BOLD_TEAL,
21+
types.BuiltinMethodType: ANSIColors.BOLD_CYAN,
22+
types.MethodType: ANSIColors.BOLD_CYAN,
23+
type((42).__add__): ANSIColors.BOLD_CYAN,
24+
type(int.__add__): ANSIColors.BOLD_CYAN,
25+
type(str.replace): ANSIColors.BOLD_CYAN,
2626

2727
types.FunctionType: ANSIColors.BOLD_BLUE,
2828
types.BuiltinFunctionType: ANSIColors.BOLD_BLUE,
2929

3030
type: ANSIColors.BOLD_MAGENTA,
3131

32-
types.ModuleType: ANSIColors.TEAL,
32+
types.ModuleType: ANSIColors.CYAN,
3333
type(None): ANSIColors.GREY,
3434
str: ANSIColors.BOLD_GREEN,
3535
bytes: ANSIColors.BOLD_GREEN,
@@ -48,7 +48,7 @@ def setup(self):
4848

4949
class Completer(rlcompleter.Completer):
5050
"""
51-
When doing someting like a.b.<TAB>, display only the attributes of
51+
When doing someting like a.b.<tab>, display only the attributes of
5252
b instead of the full a.b.attr string.
5353
5454
Optionally, display the various completions in different colors
@@ -61,10 +61,10 @@ def __init__(self, namespace=None, Config=DefaultConfig):
6161

6262
# XXX: double check what happens in this case once fancycompleter works
6363
if False and hasattr(readline, '_setup'):
64-
# this is needed to offer pyrepl a better chance to patch
65-
# raw_input. Usually, it does at import time, but is we are under
64+
# This is needed to offer PyREPL a better chance to patch
65+
# raw_input. Usually, it does at import time, but if we are under
6666
# pytest with output captured, at import time we don't have a
67-
# terminal and thus the raw_input hook is not installed
67+
# terminal and thus the raw_input hook is not installed.
6868
readline._setup()
6969

7070
if self.config.use_colors:
@@ -178,7 +178,7 @@ def colorize_matches(self, names, values):
178178
for i, name, obj
179179
in zip(count(), names, values)]
180180
# We add a space at the end to prevent the automatic completion of the
181-
# common prefix, which is the ANSI ESCAPE sequence.
181+
# common prefix, which is the ANSI escape sequence.
182182
return matches + [' ']
183183

184184
def color_for_obj(self, i, name, value):

Lib/test/test_pyrepl/test_fancycompleter.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -147,21 +147,21 @@ class A:
147147
bbb = None
148148
compl = Completer({'A': A}, ConfigForTest)
149149
#
150-
# in this case, we want to display all attributes which start with
151-
# 'a'. MOREOVER, we also include a space to prevent readline to
150+
# In this case, we want to display all attributes which start with
151+
# 'a'. Moreover, we also include a space to prevent readline to
152152
# automatically insert the common prefix (which will the the ANSI escape
153-
# sequence if we use colors)
153+
# sequence if we use colors).
154154
matches = compl.attr_matches('A.a')
155155
self.assertEqual(sorted(matches), [' ', 'aaa', 'abc_1', 'abc_2', 'abc_3'])
156156
#
157-
# IF there is an actual common prefix, we return just it, so that readline
157+
# If there is an actual common prefix, we return just it, so that readline
158158
# will insert it into place
159159
matches = compl.attr_matches('A.ab')
160160
self.assertEqual(matches, ['A.abc_'])
161161
#
162-
# finally, at the next TAB, we display again all the completions available
163-
# for this common prefix. Agai, we insert a spurious space to prevent the
164-
# automatic completion of ANSI sequences
162+
# Finally, at the next tab, we display again all the completions available
163+
# for this common prefix. Again, we insert a spurious space to prevent the
164+
# automatic completion of ANSI sequences.
165165
matches = compl.attr_matches('A.abc_')
166166
self.assertEqual(sorted(matches), [' ', 'abc_1', 'abc_2', 'abc_3'])
167167

0 commit comments

Comments
 (0)