Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitce0bd0a

Browse files
Remove ArrayItemMembersCompletion
functionality taken over by more general ExpressionAttributeCompletion
1 parent51ecedb commitce0bd0a

File tree

2 files changed

+7
-66
lines changed

2 files changed

+7
-66
lines changed

‎bpython/autocomplete.py‎

Lines changed: 1 addition & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -340,63 +340,6 @@ def list_attributes(self, obj):
340340
returndir(obj)
341341

342342

343-
classArrayItemMembersCompletion(BaseCompletionType):
344-
345-
def__init__(self,shown_before_tab=True,mode=SIMPLE):
346-
self._shown_before_tab=shown_before_tab
347-
self.completer=AttrCompletion(mode=mode)
348-
349-
defmatches(self,cursor_offset,line,**kwargs):
350-
if'locals_'notinkwargs:
351-
returnNone
352-
locals_=kwargs['locals_']
353-
354-
full=self.locate(cursor_offset,line)
355-
iffullisNone:
356-
returnNone
357-
358-
arr=lineparts.current_indexed_member_access_identifier(
359-
cursor_offset,line)
360-
index=lineparts.current_indexed_member_access_identifier_with_index(
361-
cursor_offset,line)
362-
member=lineparts.current_indexed_member_access_member(
363-
cursor_offset,line)
364-
365-
try:
366-
obj=safe_eval(arr.word,locals_)
367-
exceptEvaluationError:
368-
returnNone
369-
iftype(obj)notin (list,tuple)+string_types:
370-
# then is may be unsafe to do attribute lookup on it
371-
returnNone
372-
373-
try:
374-
locals_['temp_val_from_array']=safe_eval(index.word,locals_)
375-
except (EvaluationError,IndexError):
376-
returnNone
377-
378-
temp_line=line.replace(index.word,'temp_val_from_array.')
379-
380-
matches=self.completer.matches(len(temp_line),temp_line,**kwargs)
381-
ifmatchesisNone:
382-
returnNone
383-
384-
matches_with_correct_name= \
385-
set(match.replace('temp_val_from_array.',index.word+'.')
386-
formatchinmatchesifmatch[20:].startswith(member.word))
387-
388-
dellocals_['temp_val_from_array']
389-
390-
returnmatches_with_correct_name
391-
392-
deflocate(self,current_offset,line):
393-
a=lineparts.current_indexed_member_access(current_offset,line)
394-
returna
395-
396-
defformat(self,match):
397-
returnafter_last_dot(match)
398-
399-
400343
classDictKeyCompletion(BaseCompletionType):
401344

402345
defmatches(self,cursor_offset,line,**kwargs):
@@ -526,8 +469,7 @@ def locate(self, current_offset, line):
526469

527470

528471
classExpressionAttributeCompletion(AttrCompletion):
529-
# could replace ArrayItemMember completion and attr completion
530-
# as a more general case
472+
# could replace attr completion as a more general case with some work
531473
deflocate(self,current_offset,line):
532474
returnlineparts.current_expression_attribute(current_offset,line)
533475

@@ -676,7 +618,6 @@ def get_default_completer(mode=SIMPLE):
676618
mode=mode),
677619
AttrCompletion(mode=mode),
678620
ExpressionAttributeCompletion(mode=mode),
679-
ArrayItemMembersCompletion(mode=mode),
680621
)
681622

682623

‎bpython/test/test_autocomplete.py‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -268,20 +268,20 @@ def __getattr__(self, attr):
268268
self.com.matches(4,'a.__',locals_=locals_))
269269

270270

271-
classTestArrayItemCompletion(unittest.TestCase):
271+
classTestExpressionAttributeCompletion(unittest.TestCase):
272272
@classmethod
273273
defsetUpClass(cls):
274-
cls.com=autocomplete.ArrayItemMembersCompletion()
274+
cls.com=autocomplete.ExpressionAttributeCompletion()
275275

276276
deftest_att_matches_found_on_instance(self):
277277
self.assertSetEqual(self.com.matches(5,'a[0].',locals_={'a': [Foo()]}),
278-
set(['a[0].method','a[0].a','a[0].b']))
278+
set(['method','a','b']))
279279

280280
@skip_old_style
281281
deftest_att_matches_found_on_old_style_instance(self):
282282
self.assertSetEqual(self.com.matches(5,'a[0].',
283283
locals_={'a': [OldStyleFoo()]}),
284-
set(['a[0].method','a[0].a','a[0].b']))
284+
set(['method','a','b']))
285285

286286
deftest_other_getitem_methods_not_called(self):
287287
classFakeList(object):
@@ -293,14 +293,14 @@ def __getitem__(inner_self, i):
293293
deftest_tuples_complete(self):
294294
self.assertSetEqual(self.com.matches(5,'a[0].',
295295
locals_={'a': (Foo(),)}),
296-
set(['a[0].method','a[0].a','a[0].b']))
296+
set(['method','a','b']))
297297

298298
@unittest.skip('TODO, subclasses do not complete yet')
299299
deftest_list_subclasses_complete(self):
300300
classListSubclass(list):pass
301301
self.assertSetEqual(self.com.matches(5,'a[0].',
302302
locals_={'a':ListSubclass([Foo()])}),
303-
set(['a[0].method','a[0].a','a[0].b']))
303+
set(['method','a','b']))
304304

305305
deftest_getitem_not_called_in_list_subclasses_overriding_getitem(self):
306306
classFakeList(list):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2026 Movatter.jp