summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniël van Noord <13665637+DanielNoord@users.noreply.github.com>2023-04-30 23:19:47 +0200
committerDaniël van Noord <13665637+DanielNoord@users.noreply.github.com>2023-05-01 12:41:04 +0200
commit5b785322376c6e4640ac9cf6c76f77d276a4c04b (patch)
tree6268a7612dd8322acee3a967a1df0160cfcd9953
parent5590b79e8f37a4b3b04f4e7fb84636092430b30b (diff)
downloadastroid-git-5b785322376c6e4640ac9cf6c76f77d276a4c04b.tar.gz
Broaden annotations that are too narrow
-rw-r--r--astroid/exceptions.py8
-rw-r--r--astroid/nodes/node_classes.py4
-rw-r--r--astroid/nodes/scoped_nodes/mixin.py4
-rw-r--r--astroid/nodes/scoped_nodes/scoped_nodes.py4
-rw-r--r--astroid/typing.py5
5 files changed, 13 insertions, 12 deletions
diff --git a/astroid/exceptions.py b/astroid/exceptions.py
index 1acb2288..0bb89872 100644
--- a/astroid/exceptions.py
+++ b/astroid/exceptions.py
@@ -6,11 +6,11 @@
from __future__ import annotations
-from collections.abc import Sequence
+from collections.abc import Iterator
from typing import TYPE_CHECKING, Any
from astroid import util
-from astroid.typing import InferenceResult
+from astroid.typing import InferenceResult, SuccessfulInferenceResult
if TYPE_CHECKING:
from astroid import arguments, bases, nodes, objects
@@ -245,8 +245,8 @@ class InferenceError(ResolveError): # pylint: disable=too-many-instance-attribu
attribute: str | None = None,
unknown: InferenceResult | None = None,
assign_path: list[int] | None = None,
- caller: nodes.Call | None = None,
- stmts: Sequence[InferenceResult] | None = None,
+ caller: SuccessfulInferenceResult | None = None,
+ stmts: Iterator[InferenceResult] | None = None,
frame: InferenceResult | None = None,
call_site: arguments.CallSite | None = None,
func: InferenceResult | None = None,
diff --git a/astroid/nodes/node_classes.py b/astroid/nodes/node_classes.py
index db0c50d6..787fbc5f 100644
--- a/astroid/nodes/node_classes.py
+++ b/astroid/nodes/node_classes.py
@@ -1875,9 +1875,7 @@ class Dict(NodeNG, Instance):
:param end_col_offset: The end column this node appears on in the
source code. Note: This is after the last symbol.
"""
- self.items: list[
- tuple[SuccessfulInferenceResult, SuccessfulInferenceResult]
- ] = []
+ self.items: list[tuple[InferenceResult, InferenceResult]] = []
"""The key-value pairs contained in the dictionary."""
super().__init__(
diff --git a/astroid/nodes/scoped_nodes/mixin.py b/astroid/nodes/scoped_nodes/mixin.py
index f9f2220b..df4e7bcf 100644
--- a/astroid/nodes/scoped_nodes/mixin.py
+++ b/astroid/nodes/scoped_nodes/mixin.py
@@ -11,7 +11,7 @@ from typing import TYPE_CHECKING, TypeVar, overload
from astroid.filter_statements import _filter_stmts
from astroid.nodes import node_classes, scoped_nodes
from astroid.nodes.scoped_nodes.utils import builtin_lookup
-from astroid.typing import SuccessfulInferenceResult
+from astroid.typing import InferenceResult, SuccessfulInferenceResult
if TYPE_CHECKING:
from astroid import nodes
@@ -27,7 +27,7 @@ class LocalsDictNodeNG(node_classes.LookupMixIn):
# attributes below are set by the builder module or by raw factories
- locals: dict[str, list[SuccessfulInferenceResult]] = {}
+ locals: dict[str, list[InferenceResult]] = {}
"""A map of the name of a local variable to the node defining the local."""
def qname(self) -> str:
diff --git a/astroid/nodes/scoped_nodes/scoped_nodes.py b/astroid/nodes/scoped_nodes/scoped_nodes.py
index 994479f9..c42670b1 100644
--- a/astroid/nodes/scoped_nodes/scoped_nodes.py
+++ b/astroid/nodes/scoped_nodes/scoped_nodes.py
@@ -1821,7 +1821,7 @@ class ClassDef(
This is usually for :pep:`3115` style metaclass declaration.
"""
- self.bases: list[NodeNG] = []
+ self.bases: list[SuccessfulInferenceResult] = []
"""What the class inherits from."""
self.body: list[NodeNG] = []
@@ -1871,7 +1871,7 @@ class ClassDef(
# pylint: disable=redefined-outer-name
def postinit(
self,
- bases: list[NodeNG],
+ bases: list[SuccessfulInferenceResult],
body: list[NodeNG],
decorators: node_classes.Decorators | None,
newstyle: bool | None = None,
diff --git a/astroid/typing.py b/astroid/typing.py
index 0b6ec8e3..f42832e4 100644
--- a/astroid/typing.py
+++ b/astroid/typing.py
@@ -43,6 +43,9 @@ class AstroidManagerBrain(TypedDict):
InferenceResult = Union["nodes.NodeNG", "util.UninferableBase", "bases.Proxy"]
SuccessfulInferenceResult = Union["nodes.NodeNG", "bases.Proxy"]
+_SuccessfulInferenceResultT = TypeVar(
+ "_SuccessfulInferenceResultT", bound=SuccessfulInferenceResult
+)
ConstFactoryResult = Union[
"nodes.List",
@@ -55,7 +58,7 @@ ConstFactoryResult = Union[
InferBinaryOp = Callable[
[
- Union[_NodesT, "bases.Instance"],
+ _SuccessfulInferenceResultT,
Union["nodes.AugAssign", "nodes.BinOp"],
str,
InferenceResult,