mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-10 07:41:51 +08:00
Scope.imports -> iter_imports.
This commit is contained in:
@@ -474,7 +474,7 @@ class ModuleContext(use_metaclass(CachedMetaClass, context.TreeContext)):
|
||||
@memoize_default([])
|
||||
def star_imports(self):
|
||||
modules = []
|
||||
for i in self.tree_node.imports:
|
||||
for i in self.tree_node.iter_imports():
|
||||
if i.is_star_import():
|
||||
name = i.star_import_name()
|
||||
new = imports.infer_import(self, name)
|
||||
|
||||
@@ -245,9 +245,8 @@ class Scope(PythonBaseNode, DocstringMixin):
|
||||
def iter_classdefs(self):
|
||||
return self._search_in_scope(Class)
|
||||
|
||||
@property
|
||||
def imports(self):
|
||||
return list(self._search_in_scope(Import))
|
||||
def iter_imports(self):
|
||||
return self._search_in_scope(Import)
|
||||
|
||||
def _search_in_scope(self, typ):
|
||||
def scan(children):
|
||||
@@ -302,7 +301,7 @@ class Module(Scope):
|
||||
# parser does it in a different way and scans for the first
|
||||
# statement/import with a tokenizer (to check for syntax changes like
|
||||
# the future print statement).
|
||||
for imp in self.imports:
|
||||
for imp in self.iter_imports():
|
||||
if imp.type == 'import_from' and imp.level == 0:
|
||||
for path in imp.paths():
|
||||
if [name.value for name in path] == ['__future__', 'absolute_import']:
|
||||
|
||||
@@ -79,7 +79,7 @@ class TestSubscopes():
|
||||
|
||||
class TestImports():
|
||||
def get_import(self, source):
|
||||
return parse(source).imports[0]
|
||||
return next(parse(source).iter_imports())
|
||||
|
||||
def test_import_names(self):
|
||||
imp = self.get_import(u('import math\n'))
|
||||
|
||||
Reference in New Issue
Block a user