99from _colorize import ANSIColors
1010import rlcompleter
1111import types
12- from itertools import count
1312
1413
1514class DefaultConfig :
@@ -30,7 +29,7 @@ class DefaultConfig:
3029 type : ANSIColors .BOLD_MAGENTA ,
3130
3231 types .ModuleType : ANSIColors .CYAN ,
33- type ( None ) : ANSIColors .GREY ,
32+ types . NoneType : ANSIColors .GREY ,
3433 str : ANSIColors .BOLD_GREEN ,
3534 bytes : ANSIColors .BOLD_GREEN ,
3635 int : ANSIColors .BOLD_YELLOW ,
@@ -81,7 +80,7 @@ def complete(self, text, state):
8180 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496812
8281 """
8382 if text == "" :
84- return [ '\t ' , None ] [state ]
83+ return ( '\t ' , None ) [state ]
8584 else :
8685 return rlcompleter .Completer .complete (self , text , state )
8786
@@ -122,8 +121,7 @@ def attr_matches(self, text):
122121 return []
123122
124123 # get the content of the object, except __builtins__
125- words = set (dir (thisobject ))
126- words .discard ("__builtins__" )
124+ words = set (dir (thisobject )) - {'__builtins__' }
127125
128126 if hasattr (thisobject , '__class__' ):
129127 words .add ('__class__' )
@@ -140,8 +138,10 @@ def attr_matches(self, text):
140138 words = sorted (words )
141139 while True :
142140 for word in words :
143- if (word [:n ] == attr and
144- not (noprefix and word [:n + 1 ] == noprefix )):
141+ if (
142+ word [:n ] == attr
143+ and not (noprefix and word [:n + 1 ] == noprefix )
144+ ):
145145 try :
146146 val = getattr (thisobject , word )
147147 except Exception :
@@ -175,8 +175,8 @@ def attr_matches(self, text):
175175
176176 def colorize_matches (self , names , values ):
177177 matches = [self .color_for_obj (i , name , obj )
178- for i , name , obj
179- in zip (count (), names , values )]
178+ for i , ( name , obj )
179+ in enumerate ( zip (names , values ) )]
180180 # We add a space at the end to prevent the automatic completion of the
181181 # common prefix, which is the ANSI escape sequence.
182182 return matches + [' ' ]
@@ -191,8 +191,7 @@ def color_for_obj(self, i, name, value):
191191
192192
193193def commonprefix (names , base = '' ):
194- """ return the common prefix of all 'names' starting with 'base'
195- """
194+ """Return the common prefix of all 'names' starting with 'base'"""
196195 if base :
197196 names = [x for x in names if x .startswith (base )]
198197 if not names :
0 commit comments