mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
gh-103763: Implement PEP 695 (#103764)
This implements PEP 695, Type Parameter Syntax. It adds support for: - Generic functions (def func[T](): ...) - Generic classes (class X[T](): ...) - Type aliases (type X = ...) - New scoping when the new syntax is used within a class body - Compiler and interpreter changes to support the new syntax and scoping rules Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Co-authored-by: Eric Traut <eric@traut.com> Co-authored-by: Larry Hastings <larry@hastings.org> Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
parent
fdafdc235e
commit
24d8b88420
56 changed files with 11405 additions and 5469 deletions
|
|
@ -752,7 +752,8 @@ _PyPegen_function_def_decorators(Parser *p, asdl_expr_seq *decorators, stmt_ty f
|
|||
assert(function_def != NULL);
|
||||
if (function_def->kind == AsyncFunctionDef_kind) {
|
||||
return _PyAST_AsyncFunctionDef(
|
||||
function_def->v.FunctionDef.name, function_def->v.FunctionDef.args,
|
||||
function_def->v.FunctionDef.name, function_def->v.FunctionDef.typeparams,
|
||||
function_def->v.FunctionDef.args,
|
||||
function_def->v.FunctionDef.body, decorators, function_def->v.FunctionDef.returns,
|
||||
function_def->v.FunctionDef.type_comment, function_def->lineno,
|
||||
function_def->col_offset, function_def->end_lineno, function_def->end_col_offset,
|
||||
|
|
@ -760,7 +761,8 @@ _PyPegen_function_def_decorators(Parser *p, asdl_expr_seq *decorators, stmt_ty f
|
|||
}
|
||||
|
||||
return _PyAST_FunctionDef(
|
||||
function_def->v.FunctionDef.name, function_def->v.FunctionDef.args,
|
||||
function_def->v.FunctionDef.name, function_def->v.FunctionDef.typeparams,
|
||||
function_def->v.FunctionDef.args,
|
||||
function_def->v.FunctionDef.body, decorators,
|
||||
function_def->v.FunctionDef.returns,
|
||||
function_def->v.FunctionDef.type_comment, function_def->lineno,
|
||||
|
|
@ -774,8 +776,9 @@ _PyPegen_class_def_decorators(Parser *p, asdl_expr_seq *decorators, stmt_ty clas
|
|||
{
|
||||
assert(class_def != NULL);
|
||||
return _PyAST_ClassDef(
|
||||
class_def->v.ClassDef.name, class_def->v.ClassDef.bases,
|
||||
class_def->v.ClassDef.keywords, class_def->v.ClassDef.body, decorators,
|
||||
class_def->v.ClassDef.name, class_def->v.ClassDef.typeparams,
|
||||
class_def->v.ClassDef.bases, class_def->v.ClassDef.keywords,
|
||||
class_def->v.ClassDef.body, decorators,
|
||||
class_def->lineno, class_def->col_offset, class_def->end_lineno,
|
||||
class_def->end_col_offset, p->arena);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue