Skip to content

Commit 41fcd15

Browse files
DanielNoordcdce8p
andauthored
Type _infer of the last nodes (#1661)
Co-authored-by: Marc Mueller <[email protected]>
1 parent a62e7cf commit 41fcd15

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

astroid/inference.py

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,19 +1002,24 @@ def infer_augassign(self, context=None):
10021002

10031003

10041004
@decorators.raise_if_nothing_inferred
1005-
def infer_arguments(self, context=None):
1006-
name = context.lookupname
1007-
if name is None:
1005+
def infer_arguments(
1006+
self: nodes.Arguments, context: InferenceContext | None = None, **kwargs: Any
1007+
) -> Generator[InferenceResult, None, None]:
1008+
if context is None or context.lookupname is None:
10081009
raise InferenceError(node=self, context=context)
1009-
return protocols._arguments_infer_argname(self, name, context)
1010+
return protocols._arguments_infer_argname(self, context.lookupname, context)
10101011

10111012

10121013
nodes.Arguments._infer = infer_arguments # type: ignore[assignment]
10131014

10141015

10151016
@decorators.raise_if_nothing_inferred
10161017
@decorators.path_wrapper
1017-
def infer_assign(self, context=None):
1018+
def infer_assign(
1019+
self: nodes.AssignName | nodes.AssignAttr,
1020+
context: InferenceContext | None = None,
1021+
**kwargs: Any,
1022+
) -> Generator[InferenceResult, None, None]:
10181023
"""infer a AssignName/AssignAttr: need to inspect the RHS part of the
10191024
assign node
10201025
"""
@@ -1025,13 +1030,15 @@ def infer_assign(self, context=None):
10251030
return bases._infer_stmts(stmts, context)
10261031

10271032

1028-
nodes.AssignName._infer = infer_assign
1029-
nodes.AssignAttr._infer = infer_assign
1033+
nodes.AssignName._infer = infer_assign # type: ignore[assignment]
1034+
nodes.AssignAttr._infer = infer_assign # type: ignore[assignment]
10301035

10311036

10321037
@decorators.raise_if_nothing_inferred
10331038
@decorators.path_wrapper
1034-
def infer_empty_node(self, context=None):
1039+
def infer_empty_node(
1040+
self: nodes.EmptyNode, context: InferenceContext | None = None, **kwargs: Any
1041+
) -> Generator[InferenceResult, None, None]:
10351042
if not self.has_underlying_object():
10361043
yield util.Uninferable
10371044
else:
@@ -1046,14 +1053,6 @@ def infer_empty_node(self, context=None):
10461053
nodes.EmptyNode._infer = infer_empty_node # type: ignore[assignment]
10471054

10481055

1049-
@decorators.raise_if_nothing_inferred
1050-
def infer_index(self, context=None):
1051-
return self.value.infer(context)
1052-
1053-
1054-
nodes.Index._infer = infer_index # type: ignore[assignment]
1055-
1056-
10571056
def _populate_context_lookup(call, context):
10581057
# Allows context to be saved for later
10591058
# for inference inside a function
@@ -1072,7 +1071,9 @@ def _populate_context_lookup(call, context):
10721071

10731072

10741073
@decorators.raise_if_nothing_inferred
1075-
def infer_ifexp(self, context=None):
1074+
def infer_ifexp(
1075+
self: nodes.IfExp, context: InferenceContext | None = None, **kwargs: Any
1076+
) -> Generator[InferenceResult, None, None]:
10761077
"""Support IfExp inference
10771078
10781079
If we can't infer the truthiness of the condition, we default
@@ -1108,7 +1109,7 @@ def infer_ifexp(self, context=None):
11081109

11091110

11101111
def infer_functiondef(
1111-
self: _FunctionDefT, context: InferenceContext | None = None
1112+
self: _FunctionDefT, context: InferenceContext | None = None, **kwargs: Any
11121113
) -> Generator[Property | _FunctionDefT, None, InferenceErrorInfo]:
11131114
if not self.decorators or not bases._is_property(self):
11141115
yield self

0 commit comments

Comments
 (0)