X Tutup
Skip to content

Commit da2a126

Browse files
committed
Remove remaining lists
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
1 parent d6bb347 commit da2a126

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

bpython/line.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
and return None, or a tuple of the start index, end index, and the word"""
55

66
import re
7+
from itertools import chain
8+
79

810
current_word_re = re.compile(r'[\w_][\w0-9._]*[(]?')
911
current_dict_key_re = re.compile(r'''[\w_][\w0-9._]*\[([\w0-9._(), '"]*)''')
@@ -89,8 +91,9 @@ def current_object_attribute(cursor_offset, line):
8991
match = current_word(cursor_offset, line)
9092
if match is None: return None
9193
start, end, word = match
92-
matches = list(current_object_attribute_re.finditer(word))
93-
for m in matches[1:]:
94+
matches = current_object_attribute_re.finditer(word)
95+
matches.next()
96+
for m in matches:
9497
if m.start(1) + start <= cursor_offset and m.end(1) + start >= cursor_offset:
9598
return m.start(1) + start, m.end(1) + start, m.group(1)
9699
return None
@@ -123,8 +126,8 @@ def current_from_import_import(cursor_offset, line):
123126
match1 = current_from_import_import_re_2.search(line[baseline.end():])
124127
if match1 is None:
125128
return None
126-
matches = list(current_from_import_import_re_3.finditer(line[baseline.end():]))
127-
for m in [match1] + matches:
129+
matches = current_from_import_import_re_3.finditer(line[baseline.end():])
130+
for m in chain((match1, ), matches):
128131
start = baseline.end() + m.start(1)
129132
end = baseline.end() + m.end(1)
130133
if start < cursor_offset and end >= cursor_offset:
@@ -139,8 +142,8 @@ def current_import(cursor_offset, line):
139142
match1 = current_import_re_2.search(line[baseline.end():])
140143
if match1 is None:
141144
return None
142-
matches = list(current_import_re_3.finditer(line[baseline.end():]))
143-
for m in [match1] + matches:
145+
matches = current_import_re_3.finditer(line[baseline.end():])
146+
for m in chain((match1, ), matches):
144147
start = baseline.end() + m.start(1)
145148
end = baseline.end() + m.end(1)
146149
if start < cursor_offset and end >= cursor_offset:

0 commit comments

Comments
 (0)
X Tutup