本文整理汇总了Python中jedi.Script.goto_assignments方法的典型用法代码示例。如果您正苦于以下问题:Python Script.goto_assignments方法的具体用法?Python Script.goto_assignments怎么用?Python Script.goto_assignments使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jedi.Script
的用法示例。
在下文中一共展示了Script.goto_assignments方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _validate_import
# 需要导入模块: from jedi import Script [as 别名]
# 或者: from jedi.Script import goto_assignments [as 别名]
def _validate_import(self, module_line, lineno):
"""Try to validate the given iport line
"""
if 'noqa' in module_line:
return True
error = []
error_string = 'can\'t import {0}'
valid = True
for word in module_line.split():
if word in ('from', 'import', 'as'):
continue
offset = int(module_line.find(word) + len(word) / 2)
s = Script(self.source, lineno, offset, self.filename)
if not self.filename:
s = Script(module_line, 1, offset)
if not s.goto_assignments():
if valid is True:
valid = False
error.append(word)
err = '' if valid else error_string.format(' '.join(error))
return err, valid
示例2: make_definitions
# 需要导入模块: from jedi import Script [as 别名]
# 或者: from jedi.Script import goto_assignments [as 别名]
def make_definitions():
"""
Return a list of definitions for parametrized tests.
:rtype: [jedi.api_classes.BaseDefinition]
"""
source = dedent(
"""
import sys
class C:
pass
x = C()
def f():
pass
def g():
yield
h = lambda: None
"""
)
definitions = []
definitions += defined_names(source)
source += dedent(
"""
variable = sys or C or x or f or g or g() or h"""
)
lines = source.splitlines()
script = Script(source, len(lines), len("variable"), None)
definitions += script.goto_definitions()
script2 = Script(source, 4, len("class C"), None)
definitions += script2.usages()
source_param = "def f(a): return a"
script_param = Script(source_param, 1, len(source_param), None)
definitions += script_param.goto_assignments()
return definitions