summaryrefslogtreecommitdiff
path: root/pylint
diff options
context:
space:
mode:
authorDaniƫl van Noord <13665637+DanielNoord@users.noreply.github.com>2022-03-13 22:59:37 +0100
committerGitHub <noreply@github.com>2022-03-13 22:59:37 +0100
commit2b81cbb6d53bec271eeb7af16b57f79f10a99146 (patch)
treedd61eeac4450e682fbc925f983909045f7e5cec1 /pylint
parentdee07af04df93c4b5edeb2492eaa5c46ebcdb7b7 (diff)
downloadpylint-git-2b81cbb6d53bec271eeb7af16b57f79f10a99146.tar.gz
Fix typing of safe_infer (#5902)
Diffstat (limited to 'pylint')
-rw-r--r--pylint/checkers/utils.py8
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)