Skip to content

Commit d36c30d

Browse files
Remove StringLiteralAttrCompletion
1 parent 9a25c69 commit d36c30d

File tree

3 files changed

+10
-51
lines changed

3 files changed

+10
-51
lines changed

bpython/autocomplete.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -447,27 +447,6 @@ def locate(self, current_offset, line):
447447
return lineparts.current_word(current_offset, line)
448448

449449

450-
class StringLiteralAttrCompletion(BaseCompletionType):
451-
452-
def matches(self, cursor_offset, line, **kwargs):
453-
r = self.locate(cursor_offset, line)
454-
if r is None:
455-
return None
456-
457-
attrs = dir('')
458-
if not py3:
459-
# decode attributes
460-
attrs = (att.decode('ascii') for att in attrs)
461-
462-
matches = set(att for att in attrs if att.startswith(r.word))
463-
if not r.word.startswith('_'):
464-
return set(match for match in matches if not match.startswith('_'))
465-
return matches
466-
467-
def locate(self, current_offset, line):
468-
return lineparts.current_string_literal_attr(current_offset, line)
469-
470-
471450
class ExpressionAttributeCompletion(AttrCompletion):
472451
# could replace attr completion as a more general case with some work
473452
def locate(self, current_offset, line):
@@ -608,7 +587,6 @@ def get_completer(completers, cursor_offset, line, **kwargs):
608587
def get_default_completer(mode=SIMPLE):
609588
return (
610589
DictKeyCompletion(mode=mode),
611-
StringLiteralAttrCompletion(mode=mode),
612590
ImportCompletion(mode=mode),
613591
FilenameCompletion(mode=mode),
614592
MagicMethodCompletion(mode=mode),

bpython/line.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -216,21 +216,6 @@ def current_dotted_attribute(cursor_offset, line):
216216
return LinePart(start, end, word)
217217

218218

219-
current_string_literal_attr_re = LazyReCompile(
220-
"('''" +
221-
r'''|"""|'|")''' +
222-
r'''((?:(?=([^"'\\]+|\\.|(?!\1)["']))\3)*)\1[.]([a-zA-Z_]?[\w]*)''')
223-
224-
225-
def current_string_literal_attr(cursor_offset, line):
226-
"""The attribute following a string literal"""
227-
matches = current_string_literal_attr_re.finditer(line)
228-
for m in matches:
229-
if m.start(4) <= cursor_offset and m.end(4) >= cursor_offset:
230-
return LinePart(m.start(4), m.end(4), m.group(4))
231-
return None
232-
233-
234219
current_expression_attribute_re = LazyReCompile(r'[.]\s*((?:[\w_][\w0-9_]*)|(?:))')
235220

236221

bpython/test/test_line_properties.py

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
current_string, current_object, current_object_attribute, \
66
current_from_import_from, current_from_import_import, current_import, \
77
current_method_definition_name, current_single_word, \
8-
current_string_literal_attr, current_expression_attribute
8+
current_expression_attribute
99

1010

1111
def cursor(s):
@@ -293,19 +293,6 @@ def test_simple(self):
293293
self.assertAccess(' <foo|>')
294294

295295

296-
class TestCurrentStringLiteral(LineTestCase):
297-
def setUp(self):
298-
self.func = current_string_literal_attr
299-
300-
def test_simple(self):
301-
self.assertAccess('"hey".<a|>')
302-
self.assertAccess('"hey"|')
303-
self.assertAccess('"hey"|.a')
304-
self.assertAccess('"hey".<a|b>')
305-
self.assertAccess('"hey".asdf d|')
306-
self.assertAccess('"hey".<|>')
307-
308-
309296
class TestCurrentExpressionAttribute(LineTestCase):
310297
def setUp(self):
311298
self.func = current_expression_attribute
@@ -340,5 +327,14 @@ def test_indexing(self):
340327
self.assertAccess('abc[def].gh |i')
341328
self.assertAccess('abc[def]|')
342329

330+
def test_strings(self):
331+
self.assertAccess('"hey".<a|>')
332+
self.assertAccess('"hey"|')
333+
self.assertAccess('"hey"|.a')
334+
self.assertAccess('"hey".<a|b>')
335+
self.assertAccess('"hey".asdf d|')
336+
self.assertAccess('"hey".<|>')
337+
338+
343339
if __name__ == '__main__':
344340
unittest.main()

0 commit comments

Comments
 (0)