mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-08 06:44:46 +08:00
CompiledObject.name returns a Name now, not a string. This is more consistent with the Jedi design and doesn't lead to bugs while ducktyping.
This commit is contained in:
@@ -652,7 +652,7 @@ class Definition(use_metaclass(CachedMetaClass, BaseDefinition)):
|
|||||||
typ = d.type()
|
typ = d.type()
|
||||||
if typ == 'instance':
|
if typ == 'instance':
|
||||||
typ = 'class' # The description should be similar to Py objects.
|
typ = 'class' # The description should be similar to Py objects.
|
||||||
d = typ + ' ' + d.name
|
d = typ + ' ' + d.name.get_code()
|
||||||
elif isinstance(d, iterable.Array):
|
elif isinstance(d, iterable.Array):
|
||||||
d = 'class ' + d.type
|
d = 'class ' + d.type
|
||||||
elif isinstance(d, (pr.Class, er.Class, er.Instance)):
|
elif isinstance(d, (pr.Class, er.Class, er.Instance)):
|
||||||
|
|||||||
@@ -188,12 +188,10 @@ class CompiledObject(Base):
|
|||||||
pass # self.obj maynot have an __iter__ method.
|
pass # self.obj maynot have an __iter__ method.
|
||||||
return result
|
return result
|
||||||
|
|
||||||
"""
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
# might not exist sometimes (raises AttributeError)
|
# might not exist sometimes (raises AttributeError)
|
||||||
return self._cls().obj.__name__
|
return FakeName(self._cls().obj.__name__, self)
|
||||||
"""
|
|
||||||
|
|
||||||
def _execute_function(self, evaluator, params):
|
def _execute_function(self, evaluator, params):
|
||||||
if self.type() != 'function':
|
if self.type() != 'function':
|
||||||
|
|||||||
@@ -213,7 +213,7 @@ def _literals_to_types(evaluator, result):
|
|||||||
if is_literal(r):
|
if is_literal(r):
|
||||||
# Literals are only valid as long as the operations are
|
# Literals are only valid as long as the operations are
|
||||||
# correct. Otherwise add a value-free instance.
|
# correct. Otherwise add a value-free instance.
|
||||||
cls = builtin.get_by_name(r.name)
|
cls = builtin.get_by_name(r.name.get_code())
|
||||||
result[i] = evaluator.execute(cls)[0]
|
result[i] = evaluator.execute(cls)[0]
|
||||||
return list(set(result))
|
return list(set(result))
|
||||||
|
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ class Instance(use_metaclass(CachedMetaClass, Executed)):
|
|||||||
"""
|
"""
|
||||||
def __init__(self, evaluator, base, var_args=()):
|
def __init__(self, evaluator, base, var_args=()):
|
||||||
super(Instance, self).__init__(evaluator, base, var_args)
|
super(Instance, self).__init__(evaluator, base, var_args)
|
||||||
if str(base.name) in ['list', 'set'] \
|
if base.name.get_code() in ['list', 'set'] \
|
||||||
and compiled.builtin == base.get_parent_until():
|
and compiled.builtin == base.get_parent_until():
|
||||||
# compare the module path with the builtin name.
|
# compare the module path with the builtin name.
|
||||||
self.var_args = iterable.check_array_instances(evaluator, self)
|
self.var_args = iterable.check_array_instances(evaluator, self)
|
||||||
|
|||||||
@@ -90,14 +90,14 @@ def test_module():
|
|||||||
module = Parser(u('asdf'), 'example.py', no_docstr=True).module
|
module = Parser(u('asdf'), 'example.py', no_docstr=True).module
|
||||||
name = module.name
|
name = module.name
|
||||||
assert str(name) == 'example'
|
assert str(name) == 'example'
|
||||||
assert name.start_pos == (0, 0)
|
assert name.start_pos == (1, 0)
|
||||||
assert name.end_pos == (0, 7)
|
assert name.end_pos == (1, 7)
|
||||||
|
|
||||||
module = Parser(u('asdf'), no_docstr=True).module
|
module = Parser(u('asdf'), no_docstr=True).module
|
||||||
name = module.name
|
name = module.name
|
||||||
assert str(name) == ''
|
assert str(name) == ''
|
||||||
assert name.start_pos == (0, 0)
|
assert name.start_pos == (1, 0)
|
||||||
assert name.end_pos == (0, 0)
|
assert name.end_pos == (1, 0)
|
||||||
|
|
||||||
|
|
||||||
def test_end_pos():
|
def test_end_pos():
|
||||||
|
|||||||
Reference in New Issue
Block a user