mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 22:44:27 +08:00
Some more Python compatibility improvements.
This commit is contained in:
@@ -104,9 +104,6 @@ class CompiledObject(Base):
|
|||||||
return _parse_function_doc(self.doc)
|
return _parse_function_doc(self.doc)
|
||||||
|
|
||||||
def api_type(self):
|
def api_type(self):
|
||||||
if fake.is_class_instance(self.obj):
|
|
||||||
return 'instance'
|
|
||||||
|
|
||||||
obj = self.obj
|
obj = self.obj
|
||||||
if inspect.isclass(obj):
|
if inspect.isclass(obj):
|
||||||
return 'class'
|
return 'class'
|
||||||
@@ -115,7 +112,8 @@ class CompiledObject(Base):
|
|||||||
elif inspect.isbuiltin(obj) or inspect.ismethod(obj) \
|
elif inspect.isbuiltin(obj) or inspect.ismethod(obj) \
|
||||||
or inspect.ismethoddescriptor(obj) or inspect.isfunction(obj):
|
or inspect.ismethoddescriptor(obj) or inspect.isfunction(obj):
|
||||||
return 'function'
|
return 'function'
|
||||||
raise NotImplementedError
|
# Everything else...
|
||||||
|
return 'instance'
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def type(self):
|
def type(self):
|
||||||
@@ -190,8 +188,11 @@ class CompiledObject(Base):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
# might not exist sometimes (raises AttributeError)
|
try:
|
||||||
return FakeName(self._get_class().__name__, self)
|
name = self._get_class().__name__
|
||||||
|
except AttributeError:
|
||||||
|
name = repr(self.obj)
|
||||||
|
return FakeName(name, self)
|
||||||
|
|
||||||
def _execute_function(self, params):
|
def _execute_function(self, params):
|
||||||
if self.type != 'funcdef':
|
if self.type != 'funcdef':
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ Fallback to callee definition when definition not found.
|
|||||||
"""Parenthesis closed at next line."""
|
"""Parenthesis closed at next line."""
|
||||||
|
|
||||||
# Ignore these definitions for a little while, not sure if we really want them.
|
# Ignore these definitions for a little while, not sure if we really want them.
|
||||||
# python <= 2.7
|
# python <= 2.5
|
||||||
|
|
||||||
#? isinstance
|
#? isinstance
|
||||||
isinstance(
|
isinstance(
|
||||||
|
|||||||
Reference in New Issue
Block a user