X Tutup
Skip to content

Commit 1e11be9

Browse files
committed
EOL 80, pep8 and less parens
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
1 parent 3db074b commit 1e11be9

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

bpython/line.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
"""Extracting and changing portions of the current line
22
3-
All functions take cursor offset from the beginning of the line and the line of python code,
4-
and return None, or a tuple of the start index, end index, and the word"""
3+
All functions take cursor offset from the beginning of the line and the line of
4+
Python code, and return None, or a tuple of the start index, end index, and the
5+
word."""
56

67
import re
78
from itertools import chain
@@ -55,6 +56,7 @@ def current_word(cursor_offset, line):
5556

5657
current_dict_key_re = LazyReCompile(r'''[\w_][\w0-9._]*\[([\w0-9._(), '"]*)''')
5758

59+
5860
def current_dict_key(cursor_offset, line):
5961
"""If in dictionary completion, return the current key"""
6062
matches = current_dict_key_re.finditer(line)
@@ -94,6 +96,7 @@ def current_string(cursor_offset, line):
9496

9597
current_object_re = LazyReCompile(r'([\w_][\w0-9_]*)[.]')
9698

99+
97100
def current_object(cursor_offset, line):
98101
"""If in attribute completion, the object on which attribute should be looked up"""
99102
match = current_word(cursor_offset, line)
@@ -113,6 +116,7 @@ def current_object(cursor_offset, line):
113116

114117
current_object_attribute_re = LazyReCompile(r'([\w_][\w0-9_]*)[.]?')
115118

119+
116120
def current_object_attribute(cursor_offset, line):
117121
"""If in attribute completion, the attribute being completed"""
118122
match = current_word(cursor_offset, line)
@@ -128,6 +132,7 @@ def current_object_attribute(cursor_offset, line):
128132

129133
current_from_import_from_re = LazyReCompile(r'from ([\w0-9_.]*)(?:\s+import\s+([\w0-9_]+[,]?\s*)+)*')
130134

135+
131136
def current_from_import_from(cursor_offset, line):
132137
"""If in from import completion, the word after from
133138
@@ -150,6 +155,7 @@ def current_from_import_from(cursor_offset, line):
150155
current_from_import_import_re_2 = LazyReCompile(r'([\w0-9_]+)')
151156
current_from_import_import_re_3 = LazyReCompile(r'[,][ ]([\w0-9_]*)')
152157

158+
153159
def current_from_import_import(cursor_offset, line):
154160
"""If in from import completion, the word after import being completed
155161
@@ -174,6 +180,7 @@ def current_from_import_import(cursor_offset, line):
174180
current_import_re_2 = LazyReCompile(r'([\w0-9_.]+)')
175181
current_import_re_3 = LazyReCompile(r'[,][ ]([\w0-9_.]*)')
176182

183+
177184
def current_import(cursor_offset, line):
178185
#TODO allow for multiple as's
179186
baseline = current_import_re_1.search(line)
@@ -192,6 +199,7 @@ def current_import(cursor_offset, line):
192199

193200
current_method_definition_name_re = LazyReCompile("def\s+([a-zA-Z_][\w]*)")
194201

202+
195203
def current_method_definition_name(cursor_offset, line):
196204
"""The name of a method being defined"""
197205
matches = current_method_definition_name_re.finditer(line)
@@ -203,19 +211,21 @@ def current_method_definition_name(cursor_offset, line):
203211

204212
current_single_word_re = LazyReCompile(r"(?<![.])\b([a-zA-Z_][\w]*)")
205213

214+
206215
def current_single_word(cursor_offset, line):
207216
"""the un-dotted word just before or under the cursor"""
208217
matches = current_single_word_re.finditer(line)
209218
for m in matches:
210-
if (m.start(1) <= cursor_offset and m.end(1) >= cursor_offset):
219+
if m.start(1) <= cursor_offset and m.end(1) >= cursor_offset:
211220
return m.start(1), m.end(1), m.group(1)
212221
return None
213222

214223

215224
def current_dotted_attribute(cursor_offset, line):
216225
"""The dotted attribute-object pair before the cursor"""
217226
match = current_word(cursor_offset, line)
218-
if match is None: return None
227+
if match is None:
228+
return None
219229
start, end, word = match
220230
if '.' in word[1:]:
221231
return start, end, word
@@ -225,10 +235,11 @@ def current_dotted_attribute(cursor_offset, line):
225235
"('''" +
226236
r'''|"""|'|")((?:(?=([^"'\\]+|\\.|(?!\1)["']))\3)*)\1[.]([a-zA-Z_]?[\w]*)''')
227237

238+
228239
def current_string_literal_attr(cursor_offset, line):
229240
"""The attribute following a string literal"""
230241
matches = current_string_literal_attr_re.finditer(line)
231242
for m in matches:
232-
if (m.start(4) <= cursor_offset and m.end(4) >= cursor_offset):
243+
if m.start(4) <= cursor_offset and m.end(4) >= cursor_offset:
233244
return m.start(4), m.end(4), m.group(4)
234245
return None

0 commit comments

Comments
 (0)
X Tutup