Add a temporary api._names, to make it possible to annotate a full script with types.
This commit is contained in:
1 parent
bbf1070ad9
commit
be9e77d7d3
3 files changed
+26
-1
No files matched your search
@@ -309,6 +309,19 @@ class BaseDefinition(object):
|
||||
|
||||
return '.'.join(path if path[0] else path[1:])
|
||||
|
||||
def goto_assignments(self):
|
||||
if not isinstance(self._definition, pr.NamePart):
|
||||
raise TypeError('Definition is not a NamePart.')
|
||||
|
||||
if self.type not in ('statement', 'import'):
|
||||
# Functions, classes and modules are already fixed definitions, we
|
||||
# cannot follow them anymore.
|
||||
return [self]
|
||||
stmt_or_imp = self._definition.parent.parent
|
||||
|
||||
names, _ = self._evaluator.goto(stmt_or_imp, [self._definition])
|
||||
return [Definition(self._evaluator, n) for n in names]
|
||||
|
||||
@memoize_default()
|
||||
def _follow_statements_imports(self):
|
||||
"""
|
||||
|
||||
Reference in new issue
Block a user