Skip to content

Commit ca393dd

Browse files
authored
fix: annotated argument's var node type is explicit, not inferred (#17217)
Fixes #17216 During conversion from a standard library AST to the mypy AST, `Var` nodes were being created inside `Argument` nodes without acknowledging the presence of a type annotation, leading to the `Var` node's type as being always set as *inferred*: https://github.com/python/mypy/blob/fb31409b392c5533b25173705d62ed385ee39cfb/mypy/nodes.py#L988 This causes an error at https://github.com/python/mypy/blob/fb31409b392c5533b25173705d62ed385ee39cfb/mypyc/irbuild/expression.py#L161-L164 The fix simply acknowledges any presence of a type annotation, so the type of the relevant `Var` node is no longer considered inferred if an annotation is present.
1 parent 99dd314 commit ca393dd

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

mypy/fastparse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1116,7 +1116,7 @@ def make_argument(
11161116
if argument_elide_name(arg.arg):
11171117
pos_only = True
11181118

1119-
argument = Argument(Var(arg.arg), arg_type, self.visit(default), kind, pos_only)
1119+
argument = Argument(Var(arg.arg, arg_type), arg_type, self.visit(default), kind, pos_only)
11201120
argument.set_line(
11211121
arg.lineno,
11221122
arg.col_offset,

0 commit comments

Comments
 (0)