]>
crepu.dev Git - config.git/blob - djavu-asus/elpy/rpc-venv/lib/python3.11/site-packages/jedi/api/interpreter.py
2 TODO Some parts of this module are still not well documented.
5 from jedi
.inference
import compiled
6 from jedi
.inference
.base_value
import ValueSet
7 from jedi
.inference
.filters
import ParserTreeFilter
, MergedFilter
8 from jedi
.inference
.names
import TreeNameDefinition
9 from jedi
.inference
.compiled
import mixed
10 from jedi
.inference
.compiled
.access
import create_access_path
11 from jedi
.inference
.context
import ModuleContext
14 def _create(inference_state
, obj
):
15 return compiled
.create_from_access_path(
16 inference_state
, create_access_path(inference_state
, obj
)
20 class NamespaceObject
:
21 def __init__(self
, dct
):
25 class MixedTreeName(TreeNameDefinition
):
28 In IPython notebook it is typical that some parts of the code that is
29 provided was already executed. In that case if something is not properly
30 inferred, it should still infer from the variables it already knows.
32 inferred
= super().infer()
34 for compiled_value
in self
.parent_context
.mixed_values
:
35 for f
in compiled_value
.get_filters():
36 values
= ValueSet
.from_sets(
37 n
.infer() for n
in f
.get(self
.string_name
)
44 class MixedParserTreeFilter(ParserTreeFilter
):
45 name_class
= MixedTreeName
48 class MixedModuleContext(ModuleContext
):
49 def __init__(self
, tree_module_value
, namespaces
):
50 super().__init
__(tree_module_value
)
52 self
._get
_mixed
_object
(
53 _create(self
.inference_state
, NamespaceObject(n
))
57 def _get_mixed_object(self
, compiled_value
):
58 return mixed
.MixedObject(
59 compiled_value
=compiled_value
,
60 tree_value
=self
._value
63 def get_filters(self
, until_position
=None, origin_scope
=None):
65 MixedParserTreeFilter(
67 until_position
=until_position
,
68 origin_scope
=origin_scope
70 self
.get_global_filter(),
73 for mixed_object
in self
.mixed_values
:
74 yield from mixed_object
.get_filters(until_position
, origin_scope
)