1
0
forked from VimPlug/jedi

Make get_repr static in access.

This commit is contained in:
Dave Halter
2017-12-13 19:16:29 +01:00
parent 0acb7dcb18
commit e03afc60ef
3 changed files with 21 additions and 4 deletions

View File

@@ -164,7 +164,7 @@ class DirectObjectAccess(object):
self._obj = obj
def __repr__(self):
return '%s(%s)' % (self.__class__.__name__, self._obj)
return '%s(%s)' % (self.__class__.__name__, self.get_repr())
def _create_access(self, obj):
return create_access(self._evaluator, obj)
@@ -231,7 +231,16 @@ class DirectObjectAccess(object):
return [self._create_access_path(base) for base in self._obj.__bases__]
def get_repr(self):
return repr(self._obj)
# Try to avoid execution of the property.
type_ = type(self._obj)
if type_ == type:
return type.__repr__(self._obj)
builtins = 'builtins', '__builtin__'
if getattr_static(type_, '__module__', default='') in builtins:
# Allow direct execution of repr for builtins.
return repr(self._obj)
return object.__repr__(self._obj)
def is_class(self):
return inspect.isclass(self._obj)