]>
crepu.dev Git - config.git/blob - djavu-asus/elpy/rpc-venv/lib/python3.11/site-packages/jedi/inference/lazy_value.py
1 from jedi
.inference
.base_value
import ValueSet
, NO_VALUES
2 from jedi
.common
import monkeypatch
5 class AbstractLazyValue
:
6 def __init__(self
, data
, min=1, max=1):
12 return '<%s: %s>' % (self
.__class
__.__name
__, self
.data
)
15 raise NotImplementedError
18 class LazyKnownValue(AbstractLazyValue
):
19 """data is a Value."""
21 return ValueSet([self
.data
])
24 class LazyKnownValues(AbstractLazyValue
):
25 """data is a ValueSet."""
30 class LazyUnknownValue(AbstractLazyValue
):
31 def __init__(self
, min=1, max=1):
32 super().__init
__(None, min, max)
38 class LazyTreeValue(AbstractLazyValue
):
39 def __init__(self
, context
, node
, min=1, max=1):
40 super().__init
__(node
, min, max)
41 self
.context
= context
42 # We need to save the predefined names. It's an unfortunate side effect
43 # that needs to be tracked otherwise results will be wrong.
44 self
._predefined
_names
= dict(context
.predefined_names
)
47 with
monkeypatch(self
.context
, 'predefined_names', self
._predefined
_names
):
48 return self
.context
.infer_node(self
.data
)
51 def get_merged_lazy_value(lazy_values
):
52 if len(lazy_values
) > 1:
53 return MergedLazyValues(lazy_values
)
58 class MergedLazyValues(AbstractLazyValue
):
59 """data is a list of lazy values."""
61 return ValueSet
.from_sets(l
.infer() for l
in self
.data
)