]>
crepu.dev Git - config.git/blob - djavu-asus/elpy/rpc-venv/lib/python3.11/site-packages/jedi/inference/gradual/utils.py
1 from pathlib
import Path
3 from jedi
.inference
.gradual
.typeshed
import TYPESHED_PATH
, create_stub_module
6 def load_proper_stub_module(inference_state
, grammar
, file_io
, import_names
, module_node
):
8 This function is given a random .pyi file and should return the proper
13 assert path
.suffix
== '.pyi'
15 relative_path
= path
.relative_to(TYPESHED_PATH
)
19 # /[...]/stdlib/3/os/__init__.pyi -> stdlib/3/os/__init__
20 rest
= relative_path
.with_suffix('')
21 # Remove the stdlib/3 or third_party/3.6 part
22 import_names
= rest
.parts
[2:]
23 if rest
.name
== '__init__':
24 import_names
= import_names
[:-1]
26 if import_names
is not None:
27 actual_value_set
= inference_state
.import_module(import_names
, prefer_stubs
=False)
29 stub
= create_stub_module(
30 inference_state
, grammar
, actual_value_set
,
31 module_node
, file_io
, import_names
33 inference_state
.stub_module_cache
[import_names
] = stub