1717def current_word (cursor_offset , line ):
1818 """the object.attribute.attribute just before or under the cursor"""
1919 pos = cursor_offset
20- matches = current_word_re .finditer (line )
2120 start = pos
2221 end = pos
2322 word = None
24- for m in matches :
23+ for m in current_word_re . finditer ( line ) :
2524 if m .start (1 ) < pos and m .end (1 ) >= pos :
2625 start = m .start (1 )
2726 end = m .end (1 )
@@ -36,8 +35,7 @@ def current_word(cursor_offset, line):
3635
3736def current_dict_key (cursor_offset , line ):
3837 """If in dictionary completion, return the current key"""
39- matches = current_dict_key_re .finditer (line )
40- for m in matches :
38+ for m in current_dict_key_re .finditer (line ):
4139 if m .start (1 ) <= cursor_offset and m .end (1 ) >= cursor_offset :
4240 return LinePart (m .start (1 ), m .end (1 ), m .group (1 ))
4341 return None
@@ -48,8 +46,7 @@ def current_dict_key(cursor_offset, line):
4846
4947def current_dict (cursor_offset , line ):
5048 """If in dictionary completion, return the dict that should be used"""
51- matches = current_dict_re .finditer (line )
52- for m in matches :
49+ for m in current_dict_re .finditer (line ):
5350 if m .start (2 ) <= cursor_offset and m .end (2 ) >= cursor_offset :
5451 return LinePart (m .start (1 ), m .end (1 ), m .group (1 ))
5552 return None
@@ -84,9 +81,8 @@ def current_object(cursor_offset, line):
8481 if match is None :
8582 return None
8683 start , end , word = match
87- matches = current_object_re .finditer (word )
8884 s = ""
89- for m in matches :
85+ for m in current_object_re . finditer ( word ) :
9086 if m .end (1 ) + start < cursor_offset :
9187 if s :
9288 s += "."
@@ -132,8 +128,7 @@ def current_from_import_from(cursor_offset, line):
132128 tokens = line .split ()
133129 if not ("from" in tokens or "import" in tokens ):
134130 return None
135- matches = current_from_import_from_re .finditer (line )
136- for m in matches :
131+ for m in current_from_import_from_re .finditer (line ):
137132 if (m .start (1 ) < cursor_offset and m .end (1 ) >= cursor_offset ) or (
138133 m .start (2 ) < cursor_offset and m .end (2 ) >= cursor_offset
139134 ):
@@ -157,8 +152,10 @@ def current_from_import_import(cursor_offset, line):
157152 match1 = current_from_import_import_re_2 .search (line [baseline .end () :])
158153 if match1 is None :
159154 return None
160- matches = current_from_import_import_re_3 .finditer (line [baseline .end () :])
161- for m in chain ((match1 ,), matches ):
155+ for m in chain (
156+ (match1 ,),
157+ current_from_import_import_re_3 .finditer (line [baseline .end () :]),
158+ ):
162159 start = baseline .end () + m .start (1 )
163160 end = baseline .end () + m .end (1 )
164161 if start < cursor_offset and end >= cursor_offset :
@@ -179,8 +176,9 @@ def current_import(cursor_offset, line):
179176 match1 = current_import_re_2 .search (line [baseline .end () :])
180177 if match1 is None :
181178 return None
182- matches = current_import_re_3 .finditer (line [baseline .end () :])
183- for m in chain ((match1 ,), matches ):
179+ for m in chain (
180+ (match1 ,), current_import_re_3 .finditer (line [baseline .end () :])
181+ ):
184182 start = baseline .end () + m .start (1 )
185183 end = baseline .end () + m .end (1 )
186184 if start < cursor_offset and end >= cursor_offset :
@@ -192,8 +190,7 @@ def current_import(cursor_offset, line):
192190
193191def current_method_definition_name (cursor_offset , line ):
194192 """The name of a method being defined"""
195- matches = current_method_definition_name_re .finditer (line )
196- for m in matches :
193+ for m in current_method_definition_name_re .finditer (line ):
197194 if m .start (1 ) <= cursor_offset and m .end (1 ) >= cursor_offset :
198195 return LinePart (m .start (1 ), m .end (1 ), m .group (1 ))
199196 return None
@@ -204,8 +201,7 @@ def current_method_definition_name(cursor_offset, line):
204201
205202def current_single_word (cursor_offset , line ):
206203 """the un-dotted word just before or under the cursor"""
207- matches = current_single_word_re .finditer (line )
208- for m in matches :
204+ for m in current_single_word_re .finditer (line ):
209205 if m .start (1 ) <= cursor_offset and m .end (1 ) >= cursor_offset :
210206 return LinePart (m .start (1 ), m .end (1 ), m .group (1 ))
211207 return None
@@ -229,8 +225,7 @@ def current_dotted_attribute(cursor_offset, line):
229225def current_expression_attribute (cursor_offset , line ):
230226 """If after a dot, the attribute being completed"""
231227 # TODO replace with more general current_expression_attribute
232- matches = current_expression_attribute_re .finditer (line )
233- for m in matches :
228+ for m in current_expression_attribute_re .finditer (line ):
234229 if m .start (1 ) <= cursor_offset and m .end (1 ) >= cursor_offset :
235230 return LinePart (m .start (1 ), m .end (1 ), m .group (1 ))
236231 return None
0 commit comments