Skip to content

Filter out two underscore attributes in auto completion #568

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 5, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion bpython/autocomplete.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,12 @@ def matches(self, cursor_offset, line, **kwargs):
# TODO add open paren for methods via _callable_prefix (or decide not
# to) unless the first character is a _ filter out all attributes
# starting with a _
if not r.word.split('.')[-1].startswith('_'):
if r.word.split('.')[-1].startswith('__'):
pass
elif r.word.split('.')[-1].startswith('_'):
matches = set(match for match in matches
if not match.split('.')[-1].startswith('__'))
else:
matches = set(match for match in matches
if not match.split('.')[-1].startswith('_'))
return matches
Expand Down
6 changes: 3 additions & 3 deletions bpython/test/test_autocomplete.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,12 +245,12 @@ def test_att_matches_found_on_old_style_instance(self):
locals_={'a': OldStyleFoo()}),
set(['a.method', 'a.a', 'a.b']))
self.assertIn(u'a.__dict__',
self.com.matches(3, 'a._', locals_={'a': OldStyleFoo()}))
self.com.matches(4, 'a.__', locals_={'a': OldStyleFoo()}))

@skip_old_style
def test_att_matches_found_on_old_style_class_object(self):
self.assertIn(u'A.__dict__',
self.com.matches(3, 'A._', locals_={'A': OldStyleFoo}))
self.com.matches(4, 'A.__', locals_={'A': OldStyleFoo}))

@skip_old_style
def test_issue536(self):
Expand All @@ -260,7 +260,7 @@ def __getattr__(self, attr):

locals_ = {'a': OldStyleWithBrokenGetAttr()}
self.assertIn(u'a.__module__',
self.com.matches(3, 'a._', locals_=locals_))
self.com.matches(4, 'a.__', locals_=locals_))


class TestMagicMethodCompletion(unittest.TestCase):
Expand Down