diff --git a/jedi/inference/compiled/subprocess/functions.py b/jedi/inference/compiled/subprocess/functions.py index baa5c328..2d3ab607 100644 --- a/jedi/inference/compiled/subprocess/functions.py +++ b/jedi/inference/compiled/subprocess/functions.py @@ -1,6 +1,5 @@ import sys import os -import re import inspect import importlib import warnings @@ -102,10 +101,9 @@ def _iter_module_names(inference_state, paths): name = dir_entry.name # First Namespaces then modules/stubs if dir_entry.is_dir(): - # pycache is obviously not an interestin namespace. Also the + # pycache is obviously not an interesting namespace. Also the # name must be a valid identifier. - # TODO use str.isidentifier, once Python 2 is removed - if name != '__pycache__' and not re.search(r'\W|^\d', name): + if name != '__pycache__' and name.isidentifier(): yield name else: if name.endswith('.pyi'): # Stub files diff --git a/jedi/inference/gradual/annotation.py b/jedi/inference/gradual/annotation.py index cfc6c733..fa3aa5ae 100644 --- a/jedi/inference/gradual/annotation.py +++ b/jedi/inference/gradual/annotation.py @@ -138,8 +138,7 @@ def _infer_param(function_value, param): """ annotation = param.annotation if annotation is None: - # If no Python 3-style annotation, look for a Python 2-style comment - # annotation. + # If no Python 3-style annotation, look for a comment annotation. # Identify parameters to function in the same sequence as they would # appear in a type comment. all_params = [child for child in param.parent.children @@ -204,7 +203,8 @@ def infer_return_types(function, arguments): all_annotations = py__annotations__(function.tree_node) annotation = all_annotations.get("return", None) if annotation is None: - # If there is no Python 3-type annotation, look for a Python 2-type annotation + # If there is no Python 3-type annotation, look for an annotation + # comment. node = function.tree_node comment = parser_utils.get_following_comment_same_line(node) if comment is None: diff --git a/jedi/inference/gradual/typeshed.py b/jedi/inference/gradual/typeshed.py index a7aadb09..2f7dcf55 100644 --- a/jedi/inference/gradual/typeshed.py +++ b/jedi/inference/gradual/typeshed.py @@ -272,7 +272,7 @@ def _load_from_typeshed(inference_state, python_value_set, parent_module_value, def _try_to_load_stub_from_file(inference_state, python_value_set, file_io, import_names): try: stub_module_node = parse_stub_module(inference_state, file_io) - except OSError: # IOError is Python 2 only + except OSError: # The file that you're looking for doesn't exist (anymore). return None else: