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

Method visit_TypeAlias

mypy/fastparse.py:1859–1871  ·  view source on GitHub ↗
(self, n: ast_TypeAlias)

Source from the content-addressed store, hash-verified

1857
1858 # TypeAlias(identifier name, type_param* type_params, expr value)
1859 def visit_TypeAlias(self, n: ast_TypeAlias) -> TypeAliasStmt | AssignmentStmt:
1860 node: TypeAliasStmt | AssignmentStmt
1861 type_params = self.translate_type_params(n.type_params)
1862 self.validate_type_alias(n)
1863 value = self.visit(n.value)
1864 # Since the value is evaluated lazily, wrap the value inside a lambda.
1865 # This helps mypyc.
1866 ret = ReturnStmt(value)
1867 self.set_line(ret, n.value)
1868 value_func = LambdaExpr(body=Block([ret]))
1869 self.set_line(value_func, n.value)
1870 node = TypeAliasStmt(self.visit_Name(n.name), type_params, value_func)
1871 return self.set_line(node, n)
1872
1873
1874class TypeConverter:

Callers

nothing calls this directly

Calls 9

translate_type_paramsMethod · 0.95
validate_type_aliasMethod · 0.95
visitMethod · 0.95
set_lineMethod · 0.95
visit_NameMethod · 0.95
ReturnStmtClass · 0.90
LambdaExprClass · 0.90
BlockClass · 0.90
TypeAliasStmtClass · 0.90

Tested by

no test coverage detected