1
0
forked from VimPlug/jedi

Start fixing some of the problems with new typeshed

This commit is contained in:
Dave Halter
2026-04-28 01:41:40 +02:00
parent 2455414d1d
commit ff581e8403
6 changed files with 17 additions and 45 deletions
+3 -2
View File
@@ -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):
+2 -13
View File
@@ -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]] = {}
+1 -1
View File
@@ -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]