mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 14:04:26 +08:00
Allow for multiple returns from goto_import
This commit is contained in:
@@ -183,26 +183,25 @@ def _iter_pytest_modules(module_context, skip_own_module=False):
|
|||||||
class FixtureFilter(ParserTreeFilter):
|
class FixtureFilter(ParserTreeFilter):
|
||||||
def _filter(self, names):
|
def _filter(self, names):
|
||||||
for name in super()._filter(names):
|
for name in super()._filter(names):
|
||||||
|
# resolve possible imports before checking for a fixture
|
||||||
# resolve possible import before checking for a fixture
|
|
||||||
if name.parent.type == "import_from":
|
if name.parent.type == "import_from":
|
||||||
imported_names = goto_import(self.parent_context, name)
|
imported_names = goto_import(self.parent_context, name)
|
||||||
if not imported_names:
|
if any(
|
||||||
continue
|
self._is_fixture(imported_name.tree_name)
|
||||||
# asssume the import leads to only one name
|
for imported_name in imported_names
|
||||||
[imported_name] = imported_names
|
):
|
||||||
target_name = imported_name.tree_name
|
|
||||||
else:
|
|
||||||
target_name = name
|
|
||||||
|
|
||||||
funcdef = target_name.parent
|
|
||||||
# Class fixtures are not supported
|
|
||||||
if funcdef.type == 'funcdef':
|
|
||||||
decorated = funcdef.parent
|
|
||||||
if decorated.type == 'decorated' and self._is_fixture(decorated):
|
|
||||||
yield name
|
yield name
|
||||||
|
elif self._is_fixture(name):
|
||||||
|
yield name
|
||||||
|
|
||||||
def _is_fixture(self, decorated):
|
def _is_fixture(self, name):
|
||||||
|
funcdef = name.parent
|
||||||
|
# Class fixtures are not supported
|
||||||
|
if funcdef.type != "funcdef":
|
||||||
|
return False
|
||||||
|
decorated = funcdef.parent
|
||||||
|
if decorated.type != "decorated":
|
||||||
|
return False
|
||||||
decorators = decorated.children[0]
|
decorators = decorated.children[0]
|
||||||
if decorators.type == 'decorators':
|
if decorators.type == 'decorators':
|
||||||
decorators = decorators.children
|
decorators = decorators.children
|
||||||
|
|||||||
Reference in New Issue
Block a user