diff options
author | Daniƫl van Noord <13665637+DanielNoord@users.noreply.github.com> | 2022-03-13 22:59:37 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-13 22:59:37 +0100 |
commit | 2b81cbb6d53bec271eeb7af16b57f79f10a99146 (patch) | |
tree | dd61eeac4450e682fbc925f983909045f7e5cec1 /pylint | |
parent | dee07af04df93c4b5edeb2492eaa5c46ebcdb7b7 (diff) | |
download | pylint-git-2b81cbb6d53bec271eeb7af16b57f79f10a99146.tar.gz |
Fix typing of safe_infer (#5902)
Diffstat (limited to 'pylint')
-rw-r--r-- | pylint/checkers/utils.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/pylint/checkers/utils.py b/pylint/checkers/utils.py index 4cc413e5c..4e775e3d2 100644 --- a/pylint/checkers/utils.py +++ b/pylint/checkers/utils.py @@ -1234,7 +1234,7 @@ def supports_delitem(value: nodes.NodeNG, _: nodes.NodeNG) -> bool: return _supports_protocol(value, _supports_delitem_protocol) -def _get_python_type_of_node(node): +def _get_python_type_of_node(node: nodes.NodeNG) -> Optional[str]: pytype = getattr(node, "pytype", None) if callable(pytype): return pytype() @@ -1242,13 +1242,15 @@ def _get_python_type_of_node(node): @lru_cache(maxsize=1024) -def safe_infer(node: nodes.NodeNG, context=None) -> Optional[nodes.NodeNG]: +def safe_infer( + node: nodes.NodeNG, context: Optional[InferenceContext] = None +) -> Union[nodes.NodeNG, Type[astroid.Uninferable], None]: """Return the inferred value for the given node. Return None if inference failed or if there is some ambiguity (more than one node has been inferred of different types). """ - inferred_types = set() + inferred_types: Set[Optional[str]] = set() try: infer_gen = node.infer(context=context) value = next(infer_gen) |