diff --git a/jedi/__main__.py b/jedi/__main__.py index 14aa42cf..2c94da2f 100644 --- a/jedi/__main__.py +++ b/jedi/__main__.py @@ -27,8 +27,8 @@ def _start_linter(): paths = [path] try: - for path in paths: - for error in jedi.Script(path=path)._analysis(): + for p in paths: + for error in jedi.Script(path=p)._analysis(): print(error) except Exception: if '--pdb' in sys.argv: diff --git a/jedi/_compatibility.py b/jedi/_compatibility.py index d7008941..a7a53bdc 100644 --- a/jedi/_compatibility.py +++ b/jedi/_compatibility.py @@ -186,7 +186,6 @@ def find_module_pre_py3(string, path=None, full_name=None, is_global_search=True module_file = None if module_file is None: - code = None return None, is_package with module_file: diff --git a/jedi/inference/__init__.py b/jedi/inference/__init__.py index 91f05841..dbefc52a 100644 --- a/jedi/inference/__init__.py +++ b/jedi/inference/__init__.py @@ -63,7 +63,6 @@ only *inferes* what needs to be *inferred*. All the statements and modules that are not used are just being ignored. """ import parso -from parso import python_bytes_to_unicode from jedi.file_io import FileIO from jedi import debug @@ -186,7 +185,7 @@ class InferenceState(object): file_io = FileIO(path) code = file_io.read() # We cannot just use parso, because it doesn't use errors='replace'. - code = python_bytes_to_unicode(code, encoding=encoding, errors='replace') + code = parso.python_bytes_to_unicode(code, encoding=encoding, errors='replace') if len(code) > settings._cropped_file_size: code = code[:settings._cropped_file_size] diff --git a/jedi/inference/arguments.py b/jedi/inference/arguments.py index c68dd469..06e3ba8a 100644 --- a/jedi/inference/arguments.py +++ b/jedi/inference/arguments.py @@ -161,7 +161,9 @@ def unpack_arglist(arglist): if child == ',': continue elif child in ('*', '**'): - yield len(child.value), next(iterator) + c = next(iterator, None) + assert c is not None + yield len(child.value), c elif child.type == 'argument' and \ child.children[0] in ('*', '**'): assert len(child.children) == 2 diff --git a/jedi/inference/base_value.py b/jedi/inference/base_value.py index 891267c8..719c1ecb 100644 --- a/jedi/inference/base_value.py +++ b/jedi/inference/base_value.py @@ -70,8 +70,6 @@ class HelperValueMixin(object): yield f def goto(self, name_or_str, name_context=None, analysis_errors=True): - if name_context is None: - name_context = self from jedi.inference import finder filters = self._get_value_filters(name_or_str) names = finder.filter_name(filters, name_or_str) @@ -218,7 +216,6 @@ class Value(HelperValueMixin, BaseValue): return '' else: return clean_scope_docstring(self.tree_node) - return None def get_safe_value(self, default=sentinel): if default is sentinel: diff --git a/jedi/inference/compiled/value.py b/jedi/inference/compiled/value.py index 5b5ca0a3..61b134ad 100644 --- a/jedi/inference/compiled/value.py +++ b/jedi/inference/compiled/value.py @@ -589,9 +589,6 @@ def _parse_function_doc(doc): def create_from_name(inference_state, compiled_value, name): access_paths = compiled_value.access_handle.getattr_paths(name, default=None) - parent_context = compiled_value - if parent_context.is_class(): - parent_context = parent_context.parent_context value = None for access_path in access_paths: diff --git a/jedi/inference/gradual/annotation.py b/jedi/inference/gradual/annotation.py index 2885f8d4..49b17c76 100644 --- a/jedi/inference/gradual/annotation.py +++ b/jedi/inference/gradual/annotation.py @@ -220,8 +220,6 @@ def infer_return_types(function, arguments): function.get_default_param_context(), match.group(1).strip() ).execute_annotation() - if annotation is None: - return NO_VALUES context = function.get_default_param_context() unknown_type_vars = find_unknown_type_vars(context, annotation) diff --git a/jedi/inference/gradual/stub_value.py b/jedi/inference/gradual/stub_value.py index 1d38e832..badfff35 100644 --- a/jedi/inference/gradual/stub_value.py +++ b/jedi/inference/gradual/stub_value.py @@ -41,7 +41,7 @@ class StubModuleValue(ModuleValue): def get_filters(self, origin_scope=None): filters = super(StubModuleValue, self).get_filters(origin_scope) - next(filters) # Ignore the first filter and replace it with our own + next(filters, None) # Ignore the first filter and replace it with our own stub_filters = self._get_stub_filters(origin_scope=origin_scope) for f in stub_filters: yield f @@ -76,7 +76,7 @@ class TypingModuleWrapper(StubModuleValue): class TypingModuleContext(ModuleContext): def get_filters(self, *args, **kwargs): filters = super(TypingModuleContext, self).get_filters(*args, **kwargs) - yield TypingModuleFilterWrapper(next(filters)) + yield TypingModuleFilterWrapper(next(filters, None)) for f in filters: yield f diff --git a/jedi/inference/gradual/typeshed.py b/jedi/inference/gradual/typeshed.py index 48692aa0..005a398f 100644 --- a/jedi/inference/gradual/typeshed.py +++ b/jedi/inference/gradual/typeshed.py @@ -103,9 +103,6 @@ def import_module_decorator(func): # ``os.path``, because it's a very important one in Python # that is being achieved by messing with ``sys.modules`` in # ``os``. - python_parent = next(iter(parent_module_values)) - if python_parent is None: - python_parent, = inference_state.import_module(('os',), prefer_stubs=False) python_value_set = ValueSet.from_sets( func(inference_state, (n,), None, sys_path,) for n in [u'posixpath', u'ntpath', u'macpath', u'os2emxpath'] diff --git a/jedi/inference/references.py b/jedi/inference/references.py index d0eb9245..e48a6f15 100644 --- a/jedi/inference/references.py +++ b/jedi/inference/references.py @@ -38,8 +38,8 @@ def _resolve_names(definition_names, avoid_names=()): yield name if name.api_type == 'module': - for name in _resolve_names(name.goto(), definition_names): - yield name + for n in _resolve_names(name.goto(), definition_names): + yield n def _dictionarize(names): diff --git a/jedi/parser_utils.py b/jedi/parser_utils.py index 7f69a80c..67e39521 100644 --- a/jedi/parser_utils.py +++ b/jedi/parser_utils.py @@ -267,7 +267,6 @@ def get_parent_scope(node, include_flows=False): continue return scope scope = scope.parent - return scope get_cached_parent_scope = _get_parent_scope_cache(get_parent_scope)