|
30 | 30 | from astroid.nodes import _base_nodes
|
31 | 31 | from astroid.nodes.const import OP_PRECEDENCE
|
32 | 32 | from astroid.nodes.node_ng import NodeNG
|
33 |
| -from astroid.typing import InferenceResult, SuccessfulInferenceResult |
| 33 | +from astroid.typing import ( |
| 34 | + ConstFactoryResult, |
| 35 | + InferenceResult, |
| 36 | + SuccessfulInferenceResult, |
| 37 | +) |
34 | 38 |
|
35 | 39 | if sys.version_info >= (3, 8):
|
36 | 40 | from typing import Literal
|
@@ -64,14 +68,15 @@ def _is_const(value):
|
64 | 68 | ],
|
65 | 69 | Any,
|
66 | 70 | ]
|
67 |
| -InferLHS = Callable[ |
68 |
| - [_NodesT, Optional[InferenceContext]], |
69 |
| - typing.Generator[InferenceResult, None, None], |
70 |
| -] |
71 | 71 | InferBinaryOperation = Callable[
|
72 | 72 | [_NodesT, Optional[InferenceContext]],
|
73 | 73 | typing.Generator[Union[InferenceResult, _BadOpMessageT], None, None],
|
74 | 74 | ]
|
| 75 | +InferLHS = Callable[ |
| 76 | + [_NodesT, Optional[InferenceContext]], |
| 77 | + typing.Generator[InferenceResult, None, None], |
| 78 | +] |
| 79 | +InferUnaryOp = Callable[[_NodesT, str], ConstFactoryResult] |
75 | 80 |
|
76 | 81 |
|
77 | 82 | @decorators.raise_if_nothing_inferred
|
@@ -1906,6 +1911,8 @@ def __init__(
|
1906 | 1911 | parent=parent,
|
1907 | 1912 | )
|
1908 | 1913 |
|
| 1914 | + infer_unary_op: ClassVar[InferUnaryOp[Const]] |
| 1915 | + |
1909 | 1916 | def __getattr__(self, name):
|
1910 | 1917 | # This is needed because of Proxy's __getattr__ method.
|
1911 | 1918 | # Calling object.__new__ on this class without calling
|
@@ -2267,6 +2274,8 @@ def postinit(
|
2267 | 2274 | """
|
2268 | 2275 | self.items = items
|
2269 | 2276 |
|
| 2277 | + infer_unary_op: ClassVar[InferUnaryOp[Dict]] |
| 2278 | + |
2270 | 2279 | @classmethod
|
2271 | 2280 | def from_elements(cls, items=None):
|
2272 | 2281 | """Create a :class:`Dict` of constants from a live dictionary.
|
@@ -3390,6 +3399,8 @@ def __init__(
|
3390 | 3399 | See astroid/protocols.py for actual implementation.
|
3391 | 3400 | """
|
3392 | 3401 |
|
| 3402 | + infer_unary_op: ClassVar[InferUnaryOp[List]] |
| 3403 | + |
3393 | 3404 | def pytype(self):
|
3394 | 3405 | """Get the name of the type that this node represents.
|
3395 | 3406 |
|
@@ -3626,6 +3637,8 @@ class Set(BaseContainer):
|
3626 | 3637 | <Set.set l.1 at 0x7f23b2e71d68>
|
3627 | 3638 | """
|
3628 | 3639 |
|
| 3640 | + infer_unary_op: ClassVar[InferUnaryOp[Set]] |
| 3641 | + |
3629 | 3642 | def pytype(self):
|
3630 | 3643 | """Get the name of the type that this node represents.
|
3631 | 3644 |
|
@@ -4152,6 +4165,8 @@ def __init__(
|
4152 | 4165 | See astroid/protocols.py for actual implementation.
|
4153 | 4166 | """
|
4154 | 4167 |
|
| 4168 | + infer_unary_op: ClassVar[InferUnaryOp[Tuple]] |
| 4169 | + |
4155 | 4170 | def pytype(self):
|
4156 | 4171 | """Get the name of the type that this node represents.
|
4157 | 4172 |
|
@@ -5401,7 +5416,7 @@ def _create_dict_items(
|
5401 | 5416 | return elements
|
5402 | 5417 |
|
5403 | 5418 |
|
5404 |
| -def const_factory(value: Any) -> List | Set | Tuple | Dict | Const | EmptyNode: |
| 5419 | +def const_factory(value: Any) -> ConstFactoryResult: |
5405 | 5420 | """Return an astroid node for a python value."""
|
5406 | 5421 | assert not isinstance(value, NodeNG)
|
5407 | 5422 |
|
|
0 commit comments