1
0
forked from VimPlug/jedi

Fix most import related mypy errors

This commit is contained in:
Peter Law
2020-07-21 23:30:26 +01:00
parent c09e21ae4b
commit 35c2d660cb
8 changed files with 42 additions and 11 deletions

View File

@@ -17,16 +17,15 @@ import re
import warnings
from typing import Optional
from parso.python.tree import search_ancestor
from parso.tree import search_ancestor
from jedi import settings
from jedi import debug
from jedi.inference.utils import unite
from jedi.cache import memoize_method
from jedi.inference import imports
from jedi.inference.imports import ImportName
from jedi.inference.compiled.mixed import MixedName
from jedi.inference.gradual.typeshed import StubModuleValue
from jedi.inference.names import ImportName, SubModuleName
from jedi.inference.gradual.stub_value import StubModuleValue
from jedi.inference.gradual.conversion import convert_names, convert_values
from jedi.inference.base_value import ValueSet
from jedi.api.keywords import KeywordName
@@ -186,7 +185,7 @@ class BaseName(object):
tree_name.is_definition():
resolve = True
if isinstance(self._name, imports.SubModuleName) or resolve:
if isinstance(self._name, SubModuleName) or resolve:
for value in self._name.infer():
return value.api_type
return self._name.api_type

View File

@@ -20,7 +20,7 @@ try:
raise ImportError
else:
# Use colorama for nicer console output.
from colorama import Fore, init
from colorama import Fore, init # type: ignore[import]
from colorama import initialise
def _lazy_colorama_init(): # noqa: F811
@@ -45,7 +45,7 @@ try:
_inited = True
except ImportError:
class Fore(object):
class Fore(object): # type: ignore[no-redef]
RED = ''
GREEN = ''
YELLOW = ''

View File

@@ -2,6 +2,22 @@ from jedi.inference.compiled.value import CompiledValue, CompiledName, \
CompiledValueFilter, CompiledValueName, create_from_access_path
from jedi.inference.base_value import LazyValueWrapper
__all__ = (
'CompiledValue',
'CompiledName',
'CompiledValueFilter',
'CompiledValueName',
'create_from_access_path',
'LazyValueWrapper',
'builtin_from_name',
'ExactValue',
'create_simple_object',
'get_string_value_set',
'load_module',
)
def builtin_from_name(inference_state, string):
typing_builtins_module = inference_state.builtins_module

View File

@@ -50,7 +50,7 @@ def _get_numpy_doc_string_cls():
global _numpy_doc_string_cache
if isinstance(_numpy_doc_string_cache, (ImportError, SyntaxError)):
raise _numpy_doc_string_cache
from numpydoc.docscrape import NumpyDocString
from numpydoc.docscrape import NumpyDocString # type: ignore[import]
_numpy_doc_string_cache = NumpyDocString
return _numpy_doc_string_cache

View File

@@ -5,7 +5,8 @@ from parso import python_bytes_to_unicode
from jedi.debug import dbg
from jedi.file_io import KnownContentFileIO
from jedi.inference.imports import SubModuleName, load_module_from_path
from jedi.inference.names import SubModuleName
from jedi.inference.imports import load_module_from_path
from jedi.inference.filters import ParserTreeFilter
from jedi.inference.gradual.conversion import convert_names

View File

@@ -4,3 +4,18 @@ from jedi.inference.value.function import FunctionValue, \
MethodValue
from jedi.inference.value.instance import AnonymousInstance, BoundMethod, \
CompiledInstance, AbstractInstanceValue, TreeInstance
__all__ = (
'ModuleValue',
'ClassValue',
'FunctionValue',
'MethodValue',
'AnonymousInstance',
'BoundMethod',
'CompiledInstance',
'AbstractInstanceValue',
'TreeInstance',
)

View File

@@ -1,6 +1,6 @@
from abc import abstractproperty
from parso.python.tree import search_ancestor
from parso.tree import search_ancestor
from jedi import debug
from jedi import settings

View File

@@ -1,6 +1,6 @@
from pathlib import Path
from parso.python.tree import search_ancestor
from parso.tree import search_ancestor
from jedi.inference.cache import inference_state_method_cache
from jedi.inference.imports import load_module_from_path
from jedi.inference.filters import ParserTreeFilter