X Tutup
Skip to content

Commit 016952b

Browse files
committed
Only show the "__abstractmethods__" attribute for instances of abc.ABCMeta.
This closes issue #97.
1 parent b7d3f54 commit 016952b

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

bpython/repl.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@
4646
from bpython import importcompletion, inspection
4747
from bpython.formatter import Parenthesis
4848

49+
# Needed for special handling of __abstractmethods__
50+
# abc only exists since 2.6, so check both that it exists and that it's
51+
# the one we're expecting
52+
try:
53+
import abc
54+
abc.ABCMeta
55+
has_abc = True
56+
except (ImportError, AttributeError):
57+
has_abc = False
58+
4959
py3 = sys.version_info[0] == 3
5060

5161

@@ -339,6 +349,11 @@ def attr_lookup(self, obj, expr, attr):
339349
if hasattr(obj, '__class__'):
340350
words.append('__class__')
341351
words = words + rlcompleter.get_class_members(obj.__class__)
352+
if has_abc and not isinstance(obj.__class__, abc.ABCMeta):
353+
try:
354+
words.remove('__abstractmethods__')
355+
except ValueError:
356+
pass
342357

343358
matches = []
344359
n = len(attr)

0 commit comments

Comments
 (0)
X Tutup