diff --git a/jedi/inference/context.py b/jedi/inference/context.py index 9b6c8a76..fdf32e88 100644 --- a/jedi/inference/context.py +++ b/jedi/inference/context.py @@ -72,6 +72,9 @@ class AbstractContext(object): def py__name__(self): return self._value.py__name__() + def py__doc__(self): + return self._value.py__doc__() + def infer_node(self, node): return self.inference_state.infer_element(self, node) diff --git a/jedi/inference/docstrings.py b/jedi/inference/docstrings.py index faa63f09..7b95290d 100644 --- a/jedi/inference/docstrings.py +++ b/jedi/inference/docstrings.py @@ -183,7 +183,7 @@ def _strip_rst_role(type_str): return type_str -def _infer_for_statement_string(module_value, string): +def _infer_for_statement_string(module_context, string): code = dedent(u(""" 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 # don't need to conform with the current grammar. debug.dbg('Parse docstring code %s', string, color='BLUE') - grammar = module_value.inference_state.latest_grammar + grammar = module_context.inference_state.latest_grammar try: module = grammar.parse(code.format(indent_block(string)), error_recovery=False) except ParserSyntaxError: @@ -223,8 +223,8 @@ def _infer_for_statement_string(module_value, string): from jedi.inference.value import FunctionValue function_value = FunctionValue( - module_value.inference_state, - module_value, + module_context.inference_state, + module_context, funcdef ) 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)) -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 doesn't include tuple, list and dict literals, because the stuff they contain is executed. (Used as type information). """ - definitions = module_value.infer_node(stmt) + definitions = module_context.infer_node(stmt) return ValueSet.from_sets( - _execute_array_values(module_value.inference_state, d) + _execute_array_values(module_context.inference_state, d) for d in definitions ) diff --git a/jedi/inference/imports.py b/jedi/inference/imports.py index a0fcc63d..46cdea1a 100644 --- a/jedi/inference/imports.py +++ b/jedi/inference/imports.py @@ -542,12 +542,13 @@ def get_modules_containing_name(inference_state, modules, name): used_mod_paths = set() folders_with_names_to_be_checked = [] for m in modules: - if m.file_io is not None: - path = m.file_io.path + file_io = m.get_value().file_io + if file_io is not None: + path = file_io.path if path not in used_mod_paths: used_mod_paths.add(path) folders_with_names_to_be_checked.append(( - m.file_io.get_parent_folder(), + file_io.get_parent_folder(), m.py__package__() )) yield m diff --git a/jedi/inference/param.py b/jedi/inference/param.py index d67fbe7b..e2703103 100644 --- a/jedi/inference/param.py +++ b/jedi/inference/param.py @@ -14,7 +14,7 @@ def _add_argument_issue(error_name, lazy_value, message): node = lazy_value.data if node.parent.type == 'argument': 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):