mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 14:04:26 +08:00
Module fixes
This commit is contained in:
@@ -72,6 +72,9 @@ class AbstractContext(object):
|
|||||||
def py__name__(self):
|
def py__name__(self):
|
||||||
return self._value.py__name__()
|
return self._value.py__name__()
|
||||||
|
|
||||||
|
def py__doc__(self):
|
||||||
|
return self._value.py__doc__()
|
||||||
|
|
||||||
def infer_node(self, node):
|
def infer_node(self, node):
|
||||||
return self.inference_state.infer_element(self, node)
|
return self.inference_state.infer_element(self, node)
|
||||||
|
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ def _strip_rst_role(type_str):
|
|||||||
return type_str
|
return type_str
|
||||||
|
|
||||||
|
|
||||||
def _infer_for_statement_string(module_value, string):
|
def _infer_for_statement_string(module_context, string):
|
||||||
code = dedent(u("""
|
code = dedent(u("""
|
||||||
def pseudo_docstring_stuff():
|
def pseudo_docstring_stuff():
|
||||||
'''
|
'''
|
||||||
@@ -205,7 +205,7 @@ def _infer_for_statement_string(module_value, string):
|
|||||||
# will be impossible to use `...` (Ellipsis) as a token. Docstring types
|
# will be impossible to use `...` (Ellipsis) as a token. Docstring types
|
||||||
# don't need to conform with the current grammar.
|
# don't need to conform with the current grammar.
|
||||||
debug.dbg('Parse docstring code %s', string, color='BLUE')
|
debug.dbg('Parse docstring code %s', string, color='BLUE')
|
||||||
grammar = module_value.inference_state.latest_grammar
|
grammar = module_context.inference_state.latest_grammar
|
||||||
try:
|
try:
|
||||||
module = grammar.parse(code.format(indent_block(string)), error_recovery=False)
|
module = grammar.parse(code.format(indent_block(string)), error_recovery=False)
|
||||||
except ParserSyntaxError:
|
except ParserSyntaxError:
|
||||||
@@ -223,8 +223,8 @@ def _infer_for_statement_string(module_value, string):
|
|||||||
|
|
||||||
from jedi.inference.value import FunctionValue
|
from jedi.inference.value import FunctionValue
|
||||||
function_value = FunctionValue(
|
function_value = FunctionValue(
|
||||||
module_value.inference_state,
|
module_context.inference_state,
|
||||||
module_value,
|
module_context,
|
||||||
funcdef
|
funcdef
|
||||||
)
|
)
|
||||||
func_execution_context = function_value.get_function_execution()
|
func_execution_context = function_value.get_function_execution()
|
||||||
@@ -235,15 +235,15 @@ def _infer_for_statement_string(module_value, string):
|
|||||||
return list(_execute_types_in_stmt(func_execution_context, stmt))
|
return list(_execute_types_in_stmt(func_execution_context, stmt))
|
||||||
|
|
||||||
|
|
||||||
def _execute_types_in_stmt(module_value, stmt):
|
def _execute_types_in_stmt(module_context, stmt):
|
||||||
"""
|
"""
|
||||||
Executing all types or general elements that we find in a statement. This
|
Executing all types or general elements that we find in a statement. This
|
||||||
doesn't include tuple, list and dict literals, because the stuff they
|
doesn't include tuple, list and dict literals, because the stuff they
|
||||||
contain is executed. (Used as type information).
|
contain is executed. (Used as type information).
|
||||||
"""
|
"""
|
||||||
definitions = module_value.infer_node(stmt)
|
definitions = module_context.infer_node(stmt)
|
||||||
return ValueSet.from_sets(
|
return ValueSet.from_sets(
|
||||||
_execute_array_values(module_value.inference_state, d)
|
_execute_array_values(module_context.inference_state, d)
|
||||||
for d in definitions
|
for d in definitions
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -542,12 +542,13 @@ def get_modules_containing_name(inference_state, modules, name):
|
|||||||
used_mod_paths = set()
|
used_mod_paths = set()
|
||||||
folders_with_names_to_be_checked = []
|
folders_with_names_to_be_checked = []
|
||||||
for m in modules:
|
for m in modules:
|
||||||
if m.file_io is not None:
|
file_io = m.get_value().file_io
|
||||||
path = m.file_io.path
|
if file_io is not None:
|
||||||
|
path = file_io.path
|
||||||
if path not in used_mod_paths:
|
if path not in used_mod_paths:
|
||||||
used_mod_paths.add(path)
|
used_mod_paths.add(path)
|
||||||
folders_with_names_to_be_checked.append((
|
folders_with_names_to_be_checked.append((
|
||||||
m.file_io.get_parent_folder(),
|
file_io.get_parent_folder(),
|
||||||
m.py__package__()
|
m.py__package__()
|
||||||
))
|
))
|
||||||
yield m
|
yield m
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ def _add_argument_issue(error_name, lazy_value, message):
|
|||||||
node = lazy_value.data
|
node = lazy_value.data
|
||||||
if node.parent.type == 'argument':
|
if node.parent.type == 'argument':
|
||||||
node = node.parent
|
node = node.parent
|
||||||
return analysis.add(lazy_value.value, error_name, node, message)
|
return analysis.add(lazy_value.context, error_name, node, message)
|
||||||
|
|
||||||
|
|
||||||
class ExecutedParam(object):
|
class ExecutedParam(object):
|
||||||
|
|||||||
Reference in New Issue
Block a user