forked from VimPlug/jedi
Start fixing some of the problems with new typeshed
This commit is contained in:
@@ -779,8 +779,7 @@ def preload_module(*modules):
|
||||
:param modules: different module names, list of string.
|
||||
"""
|
||||
for m in modules:
|
||||
s = "import %s as x; x." % m
|
||||
Script(s).complete(1, len(s))
|
||||
Script(f"import {m}").infer()
|
||||
|
||||
|
||||
def set_debug_function(func_cb=debug.print_to_stdout, warnings=True,
|
||||
|
||||
@@ -14,8 +14,9 @@ def builtin_from_name(inference_state, string):
|
||||
else:
|
||||
filter_ = next(typing_builtins_module.get_filters())
|
||||
name, = filter_.get(string)
|
||||
value, = name.infer()
|
||||
return value
|
||||
# Most of the time there is only symbol, but sometimes there are different
|
||||
# sys.version_infos, where there are multiple ones, just use the first one.
|
||||
return next(iter(name.infer()))
|
||||
|
||||
|
||||
class ExactValue(LazyValueWrapper):
|
||||
|
||||
@@ -58,19 +58,8 @@ def _create_stub_map(directory_path_info):
|
||||
|
||||
|
||||
def _get_typeshed_directories(version_info):
|
||||
check_version_list = ['2and3', '3']
|
||||
for base in ['stdlib', 'third_party']:
|
||||
base_path = TYPESHED_PATH.joinpath(base)
|
||||
base_list = os.listdir(base_path)
|
||||
for base_list_entry in base_list:
|
||||
match = re.match(r'(\d+)\.(\d+)$', base_list_entry)
|
||||
if match is not None:
|
||||
if match.group(1) == '3' and int(match.group(2)) <= version_info.minor:
|
||||
check_version_list.append(base_list_entry)
|
||||
|
||||
for check_version in check_version_list:
|
||||
is_third_party = base != 'stdlib'
|
||||
yield PathInfo(str(base_path.joinpath(check_version)), is_third_party)
|
||||
yield PathInfo(str(TYPESHED_PATH.joinpath("stdlib")), False)
|
||||
yield PathInfo(str(TYPESHED_PATH.joinpath("stubs")), True)
|
||||
|
||||
|
||||
_version_cache: Dict[Tuple[int, int], Mapping[str, PathInfo]] = {}
|
||||
|
||||
@@ -19,7 +19,7 @@ def load_proper_stub_module(inference_state, grammar, file_io, import_names, mod
|
||||
# /[...]/stdlib/3/os/__init__.pyi -> stdlib/3/os/__init__
|
||||
rest = relative_path.with_suffix('')
|
||||
# Remove the stdlib/3 or third_party/3.6 part
|
||||
import_names = rest.parts[2:]
|
||||
import_names = rest.parts[1:]
|
||||
if rest.name == '__init__':
|
||||
import_names = import_names[:-1]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user