MCPcopy Index your code
hub / github.com/python/mypy / visit_AnnAssign

Method visit_AnnAssign

mypy/fastparse.py:1279–1290  ·  view source on GitHub ↗
(self, n: ast3.AnnAssign)

Source from the content-addressed store, hash-verified

1277
1278 # AnnAssign(expr target, expr annotation, expr? value, int simple)
1279 def visit_AnnAssign(self, n: ast3.AnnAssign) -> AssignmentStmt:
1280 line = n.lineno
1281 if n.value is None: # always allow 'x: int'
1282 rvalue: Expression = TempNode(AnyType(TypeOfAny.special_form), no_rhs=True)
1283 self.set_line(rvalue, n)
1284 else:
1285 rvalue = self.visit(n.value)
1286 typ = TypeConverter(self.errors, line=line).visit(n.annotation)
1287 assert typ is not None
1288 typ.column = n.annotation.col_offset
1289 s = AssignmentStmt([self.visit(n.target)], rvalue, type=typ, new_syntax=True)
1290 return self.set_line(s, n)
1291
1292 # AugAssign(expr target, operator op, expr value)
1293 def visit_AugAssign(self, n: ast3.AugAssign) -> OperatorAssignmentStmt:

Callers

nothing calls this directly

Calls 6

set_lineMethod · 0.95
visitMethod · 0.95
TempNodeClass · 0.90
AnyTypeClass · 0.90
AssignmentStmtClass · 0.90
TypeConverterClass · 0.85

Tested by

no test coverage detected