diff options
| author | Daniƫl van Noord <13665637+DanielNoord@users.noreply.github.com> | 2022-03-03 12:34:22 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-03-03 12:34:22 +0100 |
| commit | 3b8db0072402a10a3da1febf83262b3f89eda23c (patch) | |
| tree | 5f7bf6458009c53a464dfd0f85471223ba2731fb /astroid | |
| parent | 80b67a9c4c9bcbfb8a05a5311e269ae3bd55eec7 (diff) | |
| download | astroid-git-3b8db0072402a10a3da1febf83262b3f89eda23c.tar.gz | |
Add some typing to astroid.inference (#1415)
Diffstat (limited to 'astroid')
| -rw-r--r-- | astroid/inference.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/astroid/inference.py b/astroid/inference.py index 384d4e63..1fb4e93c 100644 --- a/astroid/inference.py +++ b/astroid/inference.py @@ -34,7 +34,7 @@ import ast import functools import itertools import operator -from typing import Any, Callable, Dict, Iterable, Optional +from typing import Any, Callable, Dict, Iterable, Iterator, Optional, Type, Union import wrapt @@ -837,7 +837,7 @@ def _do_compare( >>> _do_compare([1, 3], '<=', [2, 4]) util.Uninferable """ - retval = None + retval: Union[None, bool] = None if op in UNINFERABLE_OPS: return util.Uninferable op_func = COMPARE_OPS[op] @@ -862,14 +862,15 @@ def _do_compare( return util.Uninferable # (or both, but "True | False" is basically the same) + assert retval is not None return retval # it was all the same value def _infer_compare( self: nodes.Compare, context: Optional[InferenceContext] = None -) -> Any: +) -> Iterator[Union[nodes.Const, Type[util.Uninferable]]]: """Chained comparison inference logic.""" - retval = True + retval: Union[bool, Type[util.Uninferable]] = True ops = self.ops left_node = self.left @@ -887,7 +888,7 @@ def _infer_compare( break # short-circuit lhs = rhs # continue if retval is util.Uninferable: - yield retval + yield retval # type: ignore[misc] else: yield nodes.Const(retval) |
