mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 22:44:27 +08:00
little edge case of modules that don't have a scope_names_generator, which is unfortunately missing, but not really used in Jedi.
At europython's hackathon we played with it and @scoder added a small script to cython/Cython/Compiler/JediTyper.py, which makes it possible to add Cython types to a Python script.
This commit is contained in:
@@ -396,6 +396,9 @@ class Module(IsScope):
|
|||||||
For isinstance checks. fast_parser.Module also inherits from this.
|
For isinstance checks. fast_parser.Module also inherits from this.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
def scope_names_generator(self, position=None):
|
||||||
|
yield self, filter_after_position(self.get_defined_names(), position)
|
||||||
|
|
||||||
|
|
||||||
class SubModule(Scope, Module):
|
class SubModule(Scope, Module):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from jedi.parser import Parser
|
from jedi.parser import Parser
|
||||||
|
from jedi.parser import representation as pr
|
||||||
from jedi._compatibility import u
|
from jedi._compatibility import u
|
||||||
|
|
||||||
|
|
||||||
@@ -6,3 +7,7 @@ def test_import_is_nested():
|
|||||||
imp = Parser(u('import ')).module.imports[0]
|
imp = Parser(u('import ')).module.imports[0]
|
||||||
# should not raise an error, even if it's not a complete import
|
# should not raise an error, even if it's not a complete import
|
||||||
assert not imp.is_nested()
|
assert not imp.is_nested()
|
||||||
|
|
||||||
|
|
||||||
|
def test_module_scope_name_generator():
|
||||||
|
assert pr.Module().scope_names_generator()
|
||||||
|
|||||||
Reference in New Issue
Block a user