[Python-checkins] (no subject)

Batuhan Taşkaya webhook-mailer at python.org
Mon Mar 16 04:13:18 EDT 2020




To: python-checkins at python.org
Subject: bpo-39638: Keep ASDL signatures in the AST nodes (GH-18515)
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0

https://github.com/python/cpython/commit/4ab362cec6dc68c798b3e354f687cf39e207=
b9a9
commit: 4ab362cec6dc68c798b3e354f687cf39e207b9a9
branch: master
author: Batuhan Ta=C5=9Fkaya <47358913+isidentical at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2020-03-16T10:12:53+02:00
summary:

bpo-39638: Keep ASDL signatures in the AST nodes (GH-18515)

files:
A Misc/NEWS.d/next/Library/2020-02-15-20-38-11.bpo-39638.wm_RS3.rst
M Doc/whatsnew/3.9.rst
M Lib/test/test_asdl_parser.py
M Lib/test/test_ast.py
M Parser/asdl.py
M Parser/asdl_c.py
M Python/Python-ast.c

diff --git a/Doc/whatsnew/3.9.rst b/Doc/whatsnew/3.9.rst
index 1d462c21987c1..8c087c622e4d1 100644
--- a/Doc/whatsnew/3.9.rst
+++ b/Doc/whatsnew/3.9.rst
@@ -164,6 +164,9 @@ be used to unparse an :class:`ast.AST` object and produce=
 a string with code
 that would produce an equivalent :class:`ast.AST` object when parsed.
 (Contributed by Pablo Galindo and Batuhan Taskaya in :issue:`38870`.)
=20
+Added docstrings to AST nodes that contains the ASDL signature used to
+construct that node. (Contributed by Batuhan Taskaya in :issue:`39638`.)
+
 asyncio
 -------
=20
diff --git a/Lib/test/test_asdl_parser.py b/Lib/test/test_asdl_parser.py
index d3306c22184c5..2c14817aae915 100644
--- a/Lib/test/test_asdl_parser.py
+++ b/Lib/test/test_asdl_parser.py
@@ -63,10 +63,10 @@ def test_product(self):
     def test_attributes(self):
         stmt =3D self.types['stmt']
         self.assertEqual(len(stmt.attributes), 4)
-        self.assertEqual(str(stmt.attributes[0]), 'Field(int, lineno)')
-        self.assertEqual(str(stmt.attributes[1]), 'Field(int, col_offset)')
-        self.assertEqual(str(stmt.attributes[2]), 'Field(int, end_lineno, op=
t=3DTrue)')
-        self.assertEqual(str(stmt.attributes[3]), 'Field(int, end_col_offset=
, opt=3DTrue)')
+        self.assertEqual(repr(stmt.attributes[0]), 'Field(int, lineno)')
+        self.assertEqual(repr(stmt.attributes[1]), 'Field(int, col_offset)')
+        self.assertEqual(repr(stmt.attributes[2]), 'Field(int, end_lineno, o=
pt=3DTrue)')
+        self.assertEqual(repr(stmt.attributes[3]), 'Field(int, end_col_offse=
t, opt=3DTrue)')
=20
     def test_constructor_fields(self):
         ehandler =3D self.types['excepthandler']
diff --git a/Lib/test/test_ast.py b/Lib/test/test_ast.py
index 0058e932f6a3f..66f83841ce341 100644
--- a/Lib/test/test_ast.py
+++ b/Lib/test/test_ast.py
@@ -636,6 +636,16 @@ def test_issue39579_dotted_name_end_col_offset(self):
         attr_b =3D tree.body[0].decorator_list[0].value
         self.assertEqual(attr_b.end_col_offset, 4)
=20
+    def test_ast_asdl_signature(self):
+        self.assertEqual(ast.withitem.__doc__, "withitem(expr context_expr, =
expr? optional_vars)")
+        self.assertEqual(ast.GtE.__doc__, "GtE")
+        self.assertEqual(ast.Name.__doc__, "Name(identifier id, expr_context=
 ctx)")
+        self.assertEqual(ast.cmpop.__doc__, "cmpop =3D Eq | NotEq | Lt | LtE=
 | Gt | GtE | Is | IsNot | In | NotIn")
+        expressions =3D [f"     | {node.__doc__}" for node in ast.expr.__sub=
classes__()]
+        expressions[0] =3D f"expr =3D {ast.expr.__subclasses__()[0].__doc__}"
+        self.assertCountEqual(ast.expr.__doc__.split("\n"), expressions)
+
+
 class ASTHelpers_Test(unittest.TestCase):
     maxDiff =3D None
=20
diff --git a/Misc/NEWS.d/next/Library/2020-02-15-20-38-11.bpo-39638.wm_RS3.rs=
t b/Misc/NEWS.d/next/Library/2020-02-15-20-38-11.bpo-39638.wm_RS3.rst
new file mode 100644
index 0000000000000..c2f05f0b8bafb
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-02-15-20-38-11.bpo-39638.wm_RS3.rst
@@ -0,0 +1,2 @@
+Keep ASDL signatures in the docstrings for ``AST`` nodes. Patch by Batuhan
+Taskaya
diff --git a/Parser/asdl.py b/Parser/asdl.py
index 62f5c19c99fd7..5416377100c64 100644
--- a/Parser/asdl.py
+++ b/Parser/asdl.py
@@ -72,6 +72,16 @@ def __init__(self, type, name=3DNone, seq=3DFalse, opt=3DF=
alse):
         self.seq =3D seq
         self.opt =3D opt
=20
+    def __str__(self):
+        if self.seq:
+            extra =3D "*"
+        elif self.opt:
+            extra =3D "?"
+        else:
+            extra =3D ""
+
+        return "{}{} {}".format(self.type, extra, self.name)
+
     def __repr__(self):
         if self.seq:
             extra =3D ", seq=3DTrue"
diff --git a/Parser/asdl_c.py b/Parser/asdl_c.py
index 016c12ddf1497..478f0e8925b9a 100755
--- a/Parser/asdl_c.py
+++ b/Parser/asdl_c.py
@@ -60,6 +60,9 @@ def reflow_lines(s, depth):
         lines.append(padding + cur)
     return lines
=20
+def reflow_c_string(s, depth):
+    return '"%s"' % s.replace('\n', '\\n"\n%s"' % (' ' * depth * TABSIZE))
+
 def is_simple(sum):
     """Return True if a sum is a simple.
=20
@@ -71,6 +74,21 @@ def is_simple(sum):
             return False
     return True
=20
+def asdl_of(name, obj):
+    if isinstance(obj, asdl.Product) or isinstance(obj, asdl.Constructor):
+        fields =3D ", ".join(map(str, obj.fields))
+        if fields:
+            fields =3D "({})".format(fields)
+        return "{}{}".format(name, fields)
+    else:
+        if is_simple(obj):
+            types =3D " | ".join(type.name for type in obj.types)
+        else:
+            sep =3D "\n{}| ".format(" " * (len(name) + 1))
+            types =3D sep.join(
+                asdl_of(type.name, type) for type in obj.types
+            )
+        return "{} =3D {}".format(name, types)
=20
 class EmitVisitor(asdl.VisitorBase):
     """Visit that emits lines"""
@@ -764,7 +782,7 @@ def visitModule(self, mod):
 };
=20
 static PyObject *
-make_type(const char *type, PyObject* base, const char* const* fields, int n=
um_fields)
+make_type(const char *type, PyObject* base, const char* const* fields, int n=
um_fields, const char *doc)
 {
     PyObject *fnames, *result;
     int i;
@@ -778,11 +796,12 @@ def visitModule(self, mod):
         }
         PyTuple_SET_ITEM(fnames, i, field);
     }
-    result =3D PyObject_CallFunction((PyObject*)&PyType_Type, "s(O){OOOO}",
+    result =3D PyObject_CallFunction((PyObject*)&PyType_Type, "s(O){OOOOOs}",
                     type, base,
                     astmodulestate_global->_fields, fnames,
                     astmodulestate_global->__module__,
-                    astmodulestate_global->_ast);
+                    astmodulestate_global->_ast,
+                    astmodulestate_global->__doc__, doc);
     Py_DECREF(fnames);
     return result;
 }
@@ -947,8 +966,9 @@ def visitProduct(self, prod, name):
             fields =3D name+"_fields"
         else:
             fields =3D "NULL"
-        self.emit('state->%s_type =3D make_type("%s", state->AST_type, %s, %=
d);' %
+        self.emit('state->%s_type =3D make_type("%s", state->AST_type, %s, %=
d,' %
                         (name, name, fields, len(prod.fields)), 1)
+        self.emit('%s);' % reflow_c_string(asdl_of(name, prod), 2), 2, reflo=
w=3DFalse)
         self.emit("if (!state->%s_type) return 0;" % name, 1)
         self.emit_type("AST_type")
         self.emit_type("%s_type" % name)
@@ -961,8 +981,9 @@ def visitProduct(self, prod, name):
         self.emit_defaults(name, prod.attributes, 1)
=20
     def visitSum(self, sum, name):
-        self.emit('state->%s_type =3D make_type("%s", state->AST_type, NULL,=
 0);' %
+        self.emit('state->%s_type =3D make_type("%s", state->AST_type, NULL,=
 0,' %
                   (name, name), 1)
+        self.emit('%s);' % reflow_c_string(asdl_of(name, sum), 2), 2, reflow=
=3DFalse)
         self.emit_type("%s_type" % name)
         self.emit("if (!state->%s_type) return 0;" % name, 1)
         if sum.attributes:
@@ -980,8 +1001,9 @@ def visitConstructor(self, cons, name, simple):
             fields =3D cons.name+"_fields"
         else:
             fields =3D "NULL"
-        self.emit('state->%s_type =3D make_type("%s", state->%s_type, %s, %d=
);' %
+        self.emit('state->%s_type =3D make_type("%s", state->%s_type, %s, %d=
,' %
                             (cons.name, cons.name, name, fields, len(cons.fi=
elds)), 1)
+        self.emit('%s);' % reflow_c_string(asdl_of(cons.name, cons), 2), 2, =
reflow=3DFalse)
         self.emit("if (!state->%s_type) return 0;" % cons.name, 1)
         self.emit_type("%s_type" % cons.name)
         self.emit_defaults(cons.name, cons.fields, 1)
@@ -1279,8 +1301,15 @@ def generate_module_def(f, mod):
         visitor.visit(mod)
         visitor_list.add(visitor)
=20
-    state_strings =3D set(["__dict__", "_attributes", "_fields", "__module__=
", "_ast"])
-    module_state =3D set(["__dict__", "_attributes", "_fields", "__module__"=
, "_ast"])
+    state_strings =3D {
+        "_ast",
+        "_fields",
+        "__doc__",
+        "__dict__",
+        "__module__",
+        "_attributes",
+    }
+    module_state =3D state_strings.copy()
     for visitor in visitor_list:
         for identifier in visitor.identifiers:
             module_state.add(identifier)
diff --git a/Python/Python-ast.c b/Python/Python-ast.c
index ed5aba655ec63..96ecc31f7a347 100644
--- a/Python/Python-ast.c
+++ b/Python/Python-ast.c
@@ -136,6 +136,7 @@ typedef struct {
     PyObject *YieldFrom_type;
     PyObject *Yield_type;
     PyObject *__dict__;
+    PyObject *__doc__;
     PyObject *__module__;
     PyObject *_ast;
     PyObject *_attributes;
@@ -359,6 +360,7 @@ static int astmodule_clear(PyObject *module)
     Py_CLEAR(astmodulestate(module)->YieldFrom_type);
     Py_CLEAR(astmodulestate(module)->Yield_type);
     Py_CLEAR(astmodulestate(module)->__dict__);
+    Py_CLEAR(astmodulestate(module)->__doc__);
     Py_CLEAR(astmodulestate(module)->__module__);
     Py_CLEAR(astmodulestate(module)->_ast);
     Py_CLEAR(astmodulestate(module)->_attributes);
@@ -581,6 +583,7 @@ static int astmodule_traverse(PyObject *module, visitproc=
 visit, void* arg)
     Py_VISIT(astmodulestate(module)->YieldFrom_type);
     Py_VISIT(astmodulestate(module)->Yield_type);
     Py_VISIT(astmodulestate(module)->__dict__);
+    Py_VISIT(astmodulestate(module)->__doc__);
     Py_VISIT(astmodulestate(module)->__module__);
     Py_VISIT(astmodulestate(module)->_ast);
     Py_VISIT(astmodulestate(module)->_attributes);
@@ -695,6 +698,7 @@ static int init_identifiers(void)
 {
     astmodulestate *state =3D astmodulestate_global;
     if ((state->__dict__ =3D PyUnicode_InternFromString("__dict__")) =3D=3D =
NULL) return 0;
+    if ((state->__doc__ =3D PyUnicode_InternFromString("__doc__")) =3D=3D NU=
LL) return 0;
     if ((state->__module__ =3D PyUnicode_InternFromString("__module__")) =3D=
=3D NULL) return 0;
     if ((state->_ast =3D PyUnicode_InternFromString("_ast")) =3D=3D NULL) re=
turn 0;
     if ((state->_attributes =3D PyUnicode_InternFromString("_attributes")) =
=3D=3D NULL) return 0;
@@ -1225,7 +1229,7 @@ static PyType_Spec AST_type_spec =3D {
 };
=20
 static PyObject *
-make_type(const char *type, PyObject* base, const char* const* fields, int n=
um_fields)
+make_type(const char *type, PyObject* base, const char* const* fields, int n=
um_fields, const char *doc)
 {
     PyObject *fnames, *result;
     int i;
@@ -1239,11 +1243,12 @@ make_type(const char *type, PyObject* base, const cha=
r* const* fields, int num_f
         }
         PyTuple_SET_ITEM(fnames, i, field);
     }
-    result =3D PyObject_CallFunction((PyObject*)&PyType_Type, "s(O){OOOO}",
+    result =3D PyObject_CallFunction((PyObject*)&PyType_Type, "s(O){OOOOOs}",
                     type, base,
                     astmodulestate_global->_fields, fnames,
                     astmodulestate_global->__module__,
-                    astmodulestate_global->_ast);
+                    astmodulestate_global->_ast,
+                    astmodulestate_global->__doc__, doc);
     Py_DECREF(fnames);
     return result;
 }
@@ -1396,21 +1401,54 @@ static int init_types(void)
     state->AST_type =3D PyType_FromSpec(&AST_type_spec);
     if (!state->AST_type) return 0;
     if (add_ast_fields() < 0) return 0;
-    state->mod_type =3D make_type("mod", state->AST_type, NULL, 0);
+    state->mod_type =3D make_type("mod", state->AST_type, NULL, 0,
+        "mod =3D Module(stmt* body, type_ignore* type_ignores)\n"
+        "    | Interactive(stmt* body)\n"
+        "    | Expression(expr body)\n"
+        "    | FunctionType(expr* argtypes, expr returns)");
     if (!state->mod_type) return 0;
     if (!add_attributes(state->mod_type, NULL, 0)) return 0;
-    state->Module_type =3D make_type("Module", state->mod_type, Module_field=
s, 2);
+    state->Module_type =3D make_type("Module", state->mod_type, Module_field=
s, 2,
+        "Module(stmt* body, type_ignore* type_ignores)");
     if (!state->Module_type) return 0;
     state->Interactive_type =3D make_type("Interactive", state->mod_type,
-                                        Interactive_fields, 1);
+                                        Interactive_fields, 1,
+        "Interactive(stmt* body)");
     if (!state->Interactive_type) return 0;
     state->Expression_type =3D make_type("Expression", state->mod_type,
-                                       Expression_fields, 1);
+                                       Expression_fields, 1,
+        "Expression(expr body)");
     if (!state->Expression_type) return 0;
     state->FunctionType_type =3D make_type("FunctionType", state->mod_type,
-                                         FunctionType_fields, 2);
+                                         FunctionType_fields, 2,
+        "FunctionType(expr* argtypes, expr returns)");
     if (!state->FunctionType_type) return 0;
-    state->stmt_type =3D make_type("stmt", state->AST_type, NULL, 0);
+    state->stmt_type =3D make_type("stmt", state->AST_type, NULL, 0,
+        "stmt =3D FunctionDef(identifier name, arguments args, stmt* body, e=
xpr* decorator_list, expr? returns, string? type_comment)\n"
+        "     | AsyncFunctionDef(identifier name, arguments args, stmt* body=
, expr* decorator_list, expr? returns, string? type_comment)\n"
+        "     | ClassDef(identifier name, expr* bases, keyword* keywords, st=
mt* body, expr* decorator_list)\n"
+        "     | Return(expr? value)\n"
+        "     | Delete(expr* targets)\n"
+        "     | Assign(expr* targets, expr value, string? type_comment)\n"
+        "     | AugAssign(expr target, operator op, expr value)\n"
+        "     | AnnAssign(expr target, expr annotation, expr? value, int sim=
ple)\n"
+        "     | For(expr target, expr iter, stmt* body, stmt* orelse, string=
? type_comment)\n"
+        "     | AsyncFor(expr target, expr iter, stmt* body, stmt* orelse, s=
tring? type_comment)\n"
+        "     | While(expr test, stmt* body, stmt* orelse)\n"
+        "     | If(expr test, stmt* body, stmt* orelse)\n"
+        "     | With(withitem* items, stmt* body, string? type_comment)\n"
+        "     | AsyncWith(withitem* items, stmt* body, string? type_comment)=
\n"
+        "     | Raise(expr? exc, expr? cause)\n"
+        "     | Try(stmt* body, excepthandler* handlers, stmt* orelse, stmt*=
 finalbody)\n"
+        "     | Assert(expr test, expr? msg)\n"
+        "     | Import(alias* names)\n"
+        "     | ImportFrom(identifier? module, alias* names, int? level)\n"
+        "     | Global(identifier* names)\n"
+        "     | Nonlocal(identifier* names)\n"
+        "     | Expr(expr value)\n"
+        "     | Pass\n"
+        "     | Break\n"
+        "     | Continue");
     if (!state->stmt_type) return 0;
     if (!add_attributes(state->stmt_type, stmt_attributes, 4)) return 0;
     if (PyObject_SetAttr(state->stmt_type, state->end_lineno, Py_None) =3D=
=3D -1)
@@ -1419,7 +1457,8 @@ static int init_types(void)
         -1)
         return 0;
     state->FunctionDef_type =3D make_type("FunctionDef", state->stmt_type,
-                                        FunctionDef_fields, 6);
+                                        FunctionDef_fields, 6,
+        "FunctionDef(identifier name, arguments args, stmt* body, expr* deco=
rator_list, expr? returns, string? type_comment)");
     if (!state->FunctionDef_type) return 0;
     if (PyObject_SetAttr(state->FunctionDef_type, state->returns, Py_None) =
=3D=3D
         -1)
@@ -1429,7 +1468,8 @@ static int init_types(void)
         return 0;
     state->AsyncFunctionDef_type =3D make_type("AsyncFunctionDef",
                                              state->stmt_type,
-                                             AsyncFunctionDef_fields, 6);
+                                             AsyncFunctionDef_fields, 6,
+        "AsyncFunctionDef(identifier name, arguments args, stmt* body, expr*=
 decorator_list, expr? returns, string? type_comment)");
     if (!state->AsyncFunctionDef_type) return 0;
     if (PyObject_SetAttr(state->AsyncFunctionDef_type, state->returns, Py_No=
ne)
         =3D=3D -1)
@@ -1438,92 +1478,136 @@ static int init_types(void)
         Py_None) =3D=3D -1)
         return 0;
     state->ClassDef_type =3D make_type("ClassDef", state->stmt_type,
-                                     ClassDef_fields, 5);
+                                     ClassDef_fields, 5,
+        "ClassDef(identifier name, expr* bases, keyword* keywords, stmt* bod=
y, expr* decorator_list)");
     if (!state->ClassDef_type) return 0;
-    state->Return_type =3D make_type("Return", state->stmt_type, Return_fiel=
ds,
-                                   1);
+    state->Return_type =3D make_type("Return", state->stmt_type, Return_fiel=
ds, 1,
+        "Return(expr? value)");
     if (!state->Return_type) return 0;
     if (PyObject_SetAttr(state->Return_type, state->value, Py_None) =3D=3D -=
1)
         return 0;
-    state->Delete_type =3D make_type("Delete", state->stmt_type, Delete_fiel=
ds,
-                                   1);
+    state->Delete_type =3D make_type("Delete", state->stmt_type, Delete_fiel=
ds, 1,
+        "Delete(expr* targets)");
     if (!state->Delete_type) return 0;
-    state->Assign_type =3D make_type("Assign", state->stmt_type, Assign_fiel=
ds,
-                                   3);
+    state->Assign_type =3D make_type("Assign", state->stmt_type, Assign_fiel=
ds, 3,
+        "Assign(expr* targets, expr value, string? type_comment)");
     if (!state->Assign_type) return 0;
     if (PyObject_SetAttr(state->Assign_type, state->type_comment, Py_None) =
=3D=3D
         -1)
         return 0;
     state->AugAssign_type =3D make_type("AugAssign", state->stmt_type,
-                                      AugAssign_fields, 3);
+                                      AugAssign_fields, 3,
+        "AugAssign(expr target, operator op, expr value)");
     if (!state->AugAssign_type) return 0;
     state->AnnAssign_type =3D make_type("AnnAssign", state->stmt_type,
-                                      AnnAssign_fields, 4);
+                                      AnnAssign_fields, 4,
+        "AnnAssign(expr target, expr annotation, expr? value, int simple)");
     if (!state->AnnAssign_type) return 0;
     if (PyObject_SetAttr(state->AnnAssign_type, state->value, Py_None) =3D=
=3D -1)
         return 0;
-    state->For_type =3D make_type("For", state->stmt_type, For_fields, 5);
+    state->For_type =3D make_type("For", state->stmt_type, For_fields, 5,
+        "For(expr target, expr iter, stmt* body, stmt* orelse, string? type_=
comment)");
     if (!state->For_type) return 0;
     if (PyObject_SetAttr(state->For_type, state->type_comment, Py_None) =3D=
=3D -1)
         return 0;
     state->AsyncFor_type =3D make_type("AsyncFor", state->stmt_type,
-                                     AsyncFor_fields, 5);
+                                     AsyncFor_fields, 5,
+        "AsyncFor(expr target, expr iter, stmt* body, stmt* orelse, string? =
type_comment)");
     if (!state->AsyncFor_type) return 0;
     if (PyObject_SetAttr(state->AsyncFor_type, state->type_comment, Py_None)=
 =3D=3D
         -1)
         return 0;
-    state->While_type =3D make_type("While", state->stmt_type, While_fields,=
 3);
+    state->While_type =3D make_type("While", state->stmt_type, While_fields,=
 3,
+        "While(expr test, stmt* body, stmt* orelse)");
     if (!state->While_type) return 0;
-    state->If_type =3D make_type("If", state->stmt_type, If_fields, 3);
+    state->If_type =3D make_type("If", state->stmt_type, If_fields, 3,
+        "If(expr test, stmt* body, stmt* orelse)");
     if (!state->If_type) return 0;
-    state->With_type =3D make_type("With", state->stmt_type, With_fields, 3);
+    state->With_type =3D make_type("With", state->stmt_type, With_fields, 3,
+        "With(withitem* items, stmt* body, string? type_comment)");
     if (!state->With_type) return 0;
     if (PyObject_SetAttr(state->With_type, state->type_comment, Py_None) =3D=
=3D -1)
         return 0;
     state->AsyncWith_type =3D make_type("AsyncWith", state->stmt_type,
-                                      AsyncWith_fields, 3);
+                                      AsyncWith_fields, 3,
+        "AsyncWith(withitem* items, stmt* body, string? type_comment)");
     if (!state->AsyncWith_type) return 0;
     if (PyObject_SetAttr(state->AsyncWith_type, state->type_comment, Py_None)
         =3D=3D -1)
         return 0;
-    state->Raise_type =3D make_type("Raise", state->stmt_type, Raise_fields,=
 2);
+    state->Raise_type =3D make_type("Raise", state->stmt_type, Raise_fields,=
 2,
+        "Raise(expr? exc, expr? cause)");
     if (!state->Raise_type) return 0;
     if (PyObject_SetAttr(state->Raise_type, state->exc, Py_None) =3D=3D -1)
         return 0;
     if (PyObject_SetAttr(state->Raise_type, state->cause, Py_None) =3D=3D -1)
         return 0;
-    state->Try_type =3D make_type("Try", state->stmt_type, Try_fields, 4);
+    state->Try_type =3D make_type("Try", state->stmt_type, Try_fields, 4,
+        "Try(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalb=
ody)");
     if (!state->Try_type) return 0;
-    state->Assert_type =3D make_type("Assert", state->stmt_type, Assert_fiel=
ds,
-                                   2);
+    state->Assert_type =3D make_type("Assert", state->stmt_type, Assert_fiel=
ds, 2,
+        "Assert(expr test, expr? msg)");
     if (!state->Assert_type) return 0;
     if (PyObject_SetAttr(state->Assert_type, state->msg, Py_None) =3D=3D -1)
         return 0;
-    state->Import_type =3D make_type("Import", state->stmt_type, Import_fiel=
ds,
-                                   1);
+    state->Import_type =3D make_type("Import", state->stmt_type, Import_fiel=
ds, 1,
+        "Import(alias* names)");
     if (!state->Import_type) return 0;
     state->ImportFrom_type =3D make_type("ImportFrom", state->stmt_type,
-                                       ImportFrom_fields, 3);
+                                       ImportFrom_fields, 3,
+        "ImportFrom(identifier? module, alias* names, int? level)");
     if (!state->ImportFrom_type) return 0;
     if (PyObject_SetAttr(state->ImportFrom_type, state->module, Py_None) =3D=
=3D -1)
         return 0;
     if (PyObject_SetAttr(state->ImportFrom_type, state->level, Py_None) =3D=
=3D -1)
         return 0;
-    state->Global_type =3D make_type("Global", state->stmt_type, Global_fiel=
ds,
-                                   1);
+    state->Global_type =3D make_type("Global", state->stmt_type, Global_fiel=
ds, 1,
+        "Global(identifier* names)");
     if (!state->Global_type) return 0;
     state->Nonlocal_type =3D make_type("Nonlocal", state->stmt_type,
-                                     Nonlocal_fields, 1);
+                                     Nonlocal_fields, 1,
+        "Nonlocal(identifier* names)");
     if (!state->Nonlocal_type) return 0;
-    state->Expr_type =3D make_type("Expr", state->stmt_type, Expr_fields, 1);
+    state->Expr_type =3D make_type("Expr", state->stmt_type, Expr_fields, 1,
+        "Expr(expr value)");
     if (!state->Expr_type) return 0;
-    state->Pass_type =3D make_type("Pass", state->stmt_type, NULL, 0);
+    state->Pass_type =3D make_type("Pass", state->stmt_type, NULL, 0,
+        "Pass");
     if (!state->Pass_type) return 0;
-    state->Break_type =3D make_type("Break", state->stmt_type, NULL, 0);
+    state->Break_type =3D make_type("Break", state->stmt_type, NULL, 0,
+        "Break");
     if (!state->Break_type) return 0;
-    state->Continue_type =3D make_type("Continue", state->stmt_type, NULL, 0=
);
+    state->Continue_type =3D make_type("Continue", state->stmt_type, NULL, 0,
+        "Continue");
     if (!state->Continue_type) return 0;
-    state->expr_type =3D make_type("expr", state->AST_type, NULL, 0);
+    state->expr_type =3D make_type("expr", state->AST_type, NULL, 0,
+        "expr =3D BoolOp(boolop op, expr* values)\n"
+        "     | NamedExpr(expr target, expr value)\n"
+        "     | BinOp(expr left, operator op, expr right)\n"
+        "     | UnaryOp(unaryop op, expr operand)\n"
+        "     | Lambda(arguments args, expr body)\n"
+        "     | IfExp(expr test, expr body, expr orelse)\n"
+        "     | Dict(expr* keys, expr* values)\n"
+        "     | Set(expr* elts)\n"
+        "     | ListComp(expr elt, comprehension* generators)\n"
+        "     | SetComp(expr elt, comprehension* generators)\n"
+        "     | DictComp(expr key, expr value, comprehension* generators)\n"
+        "     | GeneratorExp(expr elt, comprehension* generators)\n"
+        "     | Await(expr value)\n"
+        "     | Yield(expr? value)\n"
+        "     | YieldFrom(expr value)\n"
+        "     | Compare(expr left, cmpop* ops, expr* comparators)\n"
+        "     | Call(expr func, expr* args, keyword* keywords)\n"
+        "     | FormattedValue(expr value, int? conversion, expr? format_spe=
c)\n"
+        "     | JoinedStr(expr* values)\n"
+        "     | Constant(constant value, string? kind)\n"
+        "     | Attribute(expr value, identifier attr, expr_context ctx)\n"
+        "     | Subscript(expr value, expr slice, expr_context ctx)\n"
+        "     | Starred(expr value, expr_context ctx)\n"
+        "     | Name(identifier id, expr_context ctx)\n"
+        "     | List(expr* elts, expr_context ctx)\n"
+        "     | Tuple(expr* elts, expr_context ctx)\n"
+        "     | Slice(expr? lower, expr? upper, expr? step)");
     if (!state->expr_type) return 0;
     if (!add_attributes(state->expr_type, expr_attributes, 4)) return 0;
     if (PyObject_SetAttr(state->expr_type, state->end_lineno, Py_None) =3D=
=3D -1)
@@ -1531,54 +1615,70 @@ static int init_types(void)
     if (PyObject_SetAttr(state->expr_type, state->end_col_offset, Py_None) =
=3D=3D
         -1)
         return 0;
-    state->BoolOp_type =3D make_type("BoolOp", state->expr_type, BoolOp_fiel=
ds,
-                                   2);
+    state->BoolOp_type =3D make_type("BoolOp", state->expr_type, BoolOp_fiel=
ds, 2,
+        "BoolOp(boolop op, expr* values)");
     if (!state->BoolOp_type) return 0;
     state->NamedExpr_type =3D make_type("NamedExpr", state->expr_type,
-                                      NamedExpr_fields, 2);
+                                      NamedExpr_fields, 2,
+        "NamedExpr(expr target, expr value)");
     if (!state->NamedExpr_type) return 0;
-    state->BinOp_type =3D make_type("BinOp", state->expr_type, BinOp_fields,=
 3);
+    state->BinOp_type =3D make_type("BinOp", state->expr_type, BinOp_fields,=
 3,
+        "BinOp(expr left, operator op, expr right)");
     if (!state->BinOp_type) return 0;
     state->UnaryOp_type =3D make_type("UnaryOp", state->expr_type,
-                                    UnaryOp_fields, 2);
+                                    UnaryOp_fields, 2,
+        "UnaryOp(unaryop op, expr operand)");
     if (!state->UnaryOp_type) return 0;
-    state->Lambda_type =3D make_type("Lambda", state->expr_type, Lambda_fiel=
ds,
-                                   2);
+    state->Lambda_type =3D make_type("Lambda", state->expr_type, Lambda_fiel=
ds, 2,
+        "Lambda(arguments args, expr body)");
     if (!state->Lambda_type) return 0;
-    state->IfExp_type =3D make_type("IfExp", state->expr_type, IfExp_fields,=
 3);
+    state->IfExp_type =3D make_type("IfExp", state->expr_type, IfExp_fields,=
 3,
+        "IfExp(expr test, expr body, expr orelse)");
     if (!state->IfExp_type) return 0;
-    state->Dict_type =3D make_type("Dict", state->expr_type, Dict_fields, 2);
+    state->Dict_type =3D make_type("Dict", state->expr_type, Dict_fields, 2,
+        "Dict(expr* keys, expr* values)");
     if (!state->Dict_type) return 0;
-    state->Set_type =3D make_type("Set", state->expr_type, Set_fields, 1);
+    state->Set_type =3D make_type("Set", state->expr_type, Set_fields, 1,
+        "Set(expr* elts)");
     if (!state->Set_type) return 0;
     state->ListComp_type =3D make_type("ListComp", state->expr_type,
-                                     ListComp_fields, 2);
+                                     ListComp_fields, 2,
+        "ListComp(expr elt, comprehension* generators)");
     if (!state->ListComp_type) return 0;
     state->SetComp_type =3D make_type("SetComp", state->expr_type,
-                                    SetComp_fields, 2);
+                                    SetComp_fields, 2,
+        "SetComp(expr elt, comprehension* generators)");
     if (!state->SetComp_type) return 0;
     state->DictComp_type =3D make_type("DictComp", state->expr_type,
-                                     DictComp_fields, 3);
+                                     DictComp_fields, 3,
+        "DictComp(expr key, expr value, comprehension* generators)");
     if (!state->DictComp_type) return 0;
     state->GeneratorExp_type =3D make_type("GeneratorExp", state->expr_type,
-                                         GeneratorExp_fields, 2);
+                                         GeneratorExp_fields, 2,
+        "GeneratorExp(expr elt, comprehension* generators)");
     if (!state->GeneratorExp_type) return 0;
-    state->Await_type =3D make_type("Await", state->expr_type, Await_fields,=
 1);
+    state->Await_type =3D make_type("Await", state->expr_type, Await_fields,=
 1,
+        "Await(expr value)");
     if (!state->Await_type) return 0;
-    state->Yield_type =3D make_type("Yield", state->expr_type, Yield_fields,=
 1);
+    state->Yield_type =3D make_type("Yield", state->expr_type, Yield_fields,=
 1,
+        "Yield(expr? value)");
     if (!state->Yield_type) return 0;
     if (PyObject_SetAttr(state->Yield_type, state->value, Py_None) =3D=3D -1)
         return 0;
     state->YieldFrom_type =3D make_type("YieldFrom", state->expr_type,
-                                      YieldFrom_fields, 1);
+                                      YieldFrom_fields, 1,
+        "YieldFrom(expr value)");
     if (!state->YieldFrom_type) return 0;
     state->Compare_type =3D make_type("Compare", state->expr_type,
-                                    Compare_fields, 3);
+                                    Compare_fields, 3,
+        "Compare(expr left, cmpop* ops, expr* comparators)");
     if (!state->Compare_type) return 0;
-    state->Call_type =3D make_type("Call", state->expr_type, Call_fields, 3);
+    state->Call_type =3D make_type("Call", state->expr_type, Call_fields, 3,
+        "Call(expr func, expr* args, keyword* keywords)");
     if (!state->Call_type) return 0;
     state->FormattedValue_type =3D make_type("FormattedValue", state->expr_t=
ype,
-                                           FormattedValue_fields, 3);
+                                           FormattedValue_fields, 3,
+        "FormattedValue(expr value, int? conversion, expr? format_spec)");
     if (!state->FormattedValue_type) return 0;
     if (PyObject_SetAttr(state->FormattedValue_type, state->conversion,
         Py_None) =3D=3D -1)
@@ -1587,29 +1687,38 @@ static int init_types(void)
         Py_None) =3D=3D -1)
         return 0;
     state->JoinedStr_type =3D make_type("JoinedStr", state->expr_type,
-                                      JoinedStr_fields, 1);
+                                      JoinedStr_fields, 1,
+        "JoinedStr(expr* values)");
     if (!state->JoinedStr_type) return 0;
     state->Constant_type =3D make_type("Constant", state->expr_type,
-                                     Constant_fields, 2);
+                                     Constant_fields, 2,
+        "Constant(constant value, string? kind)");
     if (!state->Constant_type) return 0;
     if (PyObject_SetAttr(state->Constant_type, state->kind, Py_None) =3D=3D =
-1)
         return 0;
     state->Attribute_type =3D make_type("Attribute", state->expr_type,
-                                      Attribute_fields, 3);
+                                      Attribute_fields, 3,
+        "Attribute(expr value, identifier attr, expr_context ctx)");
     if (!state->Attribute_type) return 0;
     state->Subscript_type =3D make_type("Subscript", state->expr_type,
-                                      Subscript_fields, 3);
+                                      Subscript_fields, 3,
+        "Subscript(expr value, expr slice, expr_context ctx)");
     if (!state->Subscript_type) return 0;
     state->Starred_type =3D make_type("Starred", state->expr_type,
-                                    Starred_fields, 2);
+                                    Starred_fields, 2,
+        "Starred(expr value, expr_context ctx)");
     if (!state->Starred_type) return 0;
-    state->Name_type =3D make_type("Name", state->expr_type, Name_fields, 2);
+    state->Name_type =3D make_type("Name", state->expr_type, Name_fields, 2,
+        "Name(identifier id, expr_context ctx)");
     if (!state->Name_type) return 0;
-    state->List_type =3D make_type("List", state->expr_type, List_fields, 2);
+    state->List_type =3D make_type("List", state->expr_type, List_fields, 2,
+        "List(expr* elts, expr_context ctx)");
     if (!state->List_type) return 0;
-    state->Tuple_type =3D make_type("Tuple", state->expr_type, Tuple_fields,=
 2);
+    state->Tuple_type =3D make_type("Tuple", state->expr_type, Tuple_fields,=
 2,
+        "Tuple(expr* elts, expr_context ctx)");
     if (!state->Tuple_type) return 0;
-    state->Slice_type =3D make_type("Slice", state->expr_type, Slice_fields,=
 3);
+    state->Slice_type =3D make_type("Slice", state->expr_type, Slice_fields,=
 3,
+        "Slice(expr? lower, expr? upper, expr? step)");
     if (!state->Slice_type) return 0;
     if (PyObject_SetAttr(state->Slice_type, state->lower, Py_None) =3D=3D -1)
         return 0;
@@ -1618,208 +1727,249 @@ static int init_types(void)
     if (PyObject_SetAttr(state->Slice_type, state->step, Py_None) =3D=3D -1)
         return 0;
     state->expr_context_type =3D make_type("expr_context", state->AST_type, =
NULL,
-                                         0);
+                                         0,
+        "expr_context =3D Load | Store | Del | AugLoad | AugStore");
     if (!state->expr_context_type) return 0;
     if (!add_attributes(state->expr_context_type, NULL, 0)) return 0;
-    state->Load_type =3D make_type("Load", state->expr_context_type, NULL, 0=
);
+    state->Load_type =3D make_type("Load", state->expr_context_type, NULL, 0,
+        "Load");
     if (!state->Load_type) return 0;
     state->Load_singleton =3D PyType_GenericNew((PyTypeObject *)state->Load_=
type,
                                               NULL, NULL);
     if (!state->Load_singleton) return 0;
-    state->Store_type =3D make_type("Store", state->expr_context_type, NULL,=
 0);
+    state->Store_type =3D make_type("Store", state->expr_context_type, NULL,=
 0,
+        "Store");
     if (!state->Store_type) return 0;
     state->Store_singleton =3D PyType_GenericNew((PyTypeObject
                                                *)state->Store_type, NULL, NU=
LL);
     if (!state->Store_singleton) return 0;
-    state->Del_type =3D make_type("Del", state->expr_context_type, NULL, 0);
+    state->Del_type =3D make_type("Del", state->expr_context_type, NULL, 0,
+        "Del");
     if (!state->Del_type) return 0;
     state->Del_singleton =3D PyType_GenericNew((PyTypeObject *)state->Del_ty=
pe,
                                              NULL, NULL);
     if (!state->Del_singleton) return 0;
     state->AugLoad_type =3D make_type("AugLoad", state->expr_context_type, N=
ULL,
-                                    0);
+                                    0,
+        "AugLoad");
     if (!state->AugLoad_type) return 0;
     state->AugLoad_singleton =3D PyType_GenericNew((PyTypeObject
                                                  *)state->AugLoad_type, NULL,
                                                  NULL);
     if (!state->AugLoad_singleton) return 0;
     state->AugStore_type =3D make_type("AugStore", state->expr_context_type,
-                                     NULL, 0);
+                                     NULL, 0,
+        "AugStore");
     if (!state->AugStore_type) return 0;
     state->AugStore_singleton =3D PyType_GenericNew((PyTypeObject
                                                   *)state->AugStore_type, NU=
LL,
                                                   NULL);
     if (!state->AugStore_singleton) return 0;
-    state->boolop_type =3D make_type("boolop", state->AST_type, NULL, 0);
+    state->boolop_type =3D make_type("boolop", state->AST_type, NULL, 0,
+        "boolop =3D And | Or");
     if (!state->boolop_type) return 0;
     if (!add_attributes(state->boolop_type, NULL, 0)) return 0;
-    state->And_type =3D make_type("And", state->boolop_type, NULL, 0);
+    state->And_type =3D make_type("And", state->boolop_type, NULL, 0,
+        "And");
     if (!state->And_type) return 0;
     state->And_singleton =3D PyType_GenericNew((PyTypeObject *)state->And_ty=
pe,
                                              NULL, NULL);
     if (!state->And_singleton) return 0;
-    state->Or_type =3D make_type("Or", state->boolop_type, NULL, 0);
+    state->Or_type =3D make_type("Or", state->boolop_type, NULL, 0,
+        "Or");
     if (!state->Or_type) return 0;
     state->Or_singleton =3D PyType_GenericNew((PyTypeObject *)state->Or_type,
                                             NULL, NULL);
     if (!state->Or_singleton) return 0;
-    state->operator_type =3D make_type("operator", state->AST_type, NULL, 0);
+    state->operator_type =3D make_type("operator", state->AST_type, NULL, 0,
+        "operator =3D Add | Sub | Mult | MatMult | Div | Mod | Pow | LShift =
| RShift | BitOr | BitXor | BitAnd | FloorDiv");
     if (!state->operator_type) return 0;
     if (!add_attributes(state->operator_type, NULL, 0)) return 0;
-    state->Add_type =3D make_type("Add", state->operator_type, NULL, 0);
+    state->Add_type =3D make_type("Add", state->operator_type, NULL, 0,
+        "Add");
     if (!state->Add_type) return 0;
     state->Add_singleton =3D PyType_GenericNew((PyTypeObject *)state->Add_ty=
pe,
                                              NULL, NULL);
     if (!state->Add_singleton) return 0;
-    state->Sub_type =3D make_type("Sub", state->operator_type, NULL, 0);
+    state->Sub_type =3D make_type("Sub", state->operator_type, NULL, 0,
+        "Sub");
     if (!state->Sub_type) return 0;
     state->Sub_singleton =3D PyType_GenericNew((PyTypeObject *)state->Sub_ty=
pe,
                                              NULL, NULL);
     if (!state->Sub_singleton) return 0;
-    state->Mult_type =3D make_type("Mult", state->operator_type, NULL, 0);
+    state->Mult_type =3D make_type("Mult", state->operator_type, NULL, 0,
+        "Mult");
     if (!state->Mult_type) return 0;
     state->Mult_singleton =3D PyType_GenericNew((PyTypeObject *)state->Mult_=
type,
                                               NULL, NULL);
     if (!state->Mult_singleton) return 0;
-    state->MatMult_type =3D make_type("MatMult", state->operator_type, NULL,=
 0);
+    state->MatMult_type =3D make_type("MatMult", state->operator_type, NULL,=
 0,
+        "MatMult");
     if (!state->MatMult_type) return 0;
     state->MatMult_singleton =3D PyType_GenericNew((PyTypeObject
                                                  *)state->MatMult_type, NULL,
                                                  NULL);
     if (!state->MatMult_singleton) return 0;
-    state->Div_type =3D make_type("Div", state->operator_type, NULL, 0);
+    state->Div_type =3D make_type("Div", state->operator_type, NULL, 0,
+        "Div");
     if (!state->Div_type) return 0;
     state->Div_singleton =3D PyType_GenericNew((PyTypeObject *)state->Div_ty=
pe,
                                              NULL, NULL);
     if (!state->Div_singleton) return 0;
-    state->Mod_type =3D make_type("Mod", state->operator_type, NULL, 0);
+    state->Mod_type =3D make_type("Mod", state->operator_type, NULL, 0,
+        "Mod");
     if (!state->Mod_type) return 0;
     state->Mod_singleton =3D PyType_GenericNew((PyTypeObject *)state->Mod_ty=
pe,
                                              NULL, NULL);
     if (!state->Mod_singleton) return 0;
-    state->Pow_type =3D make_type("Pow", state->operator_type, NULL, 0);
+    state->Pow_type =3D make_type("Pow", state->operator_type, NULL, 0,
+        "Pow");
     if (!state->Pow_type) return 0;
     state->Pow_singleton =3D PyType_GenericNew((PyTypeObject *)state->Pow_ty=
pe,
                                              NULL, NULL);
     if (!state->Pow_singleton) return 0;
-    state->LShift_type =3D make_type("LShift", state->operator_type, NULL, 0=
);
+    state->LShift_type =3D make_type("LShift", state->operator_type, NULL, 0,
+        "LShift");
     if (!state->LShift_type) return 0;
     state->LShift_singleton =3D PyType_GenericNew((PyTypeObject
                                                 *)state->LShift_type, NULL,
                                                 NULL);
     if (!state->LShift_singleton) return 0;
-    state->RShift_type =3D make_type("RShift", state->operator_type, NULL, 0=
);
+    state->RShift_type =3D make_type("RShift", state->operator_type, NULL, 0,
+        "RShift");
     if (!state->RShift_type) return 0;
     state->RShift_singleton =3D PyType_GenericNew((PyTypeObject
                                                 *)state->RShift_type, NULL,
                                                 NULL);
     if (!state->RShift_singleton) return 0;
-    state->BitOr_type =3D make_type("BitOr", state->operator_type, NULL, 0);
+    state->BitOr_type =3D make_type("BitOr", state->operator_type, NULL, 0,
+        "BitOr");
     if (!state->BitOr_type) return 0;
     state->BitOr_singleton =3D PyType_GenericNew((PyTypeObject
                                                *)state->BitOr_type, NULL, NU=
LL);
     if (!state->BitOr_singleton) return 0;
-    state->BitXor_type =3D make_type("BitXor", state->operator_type, NULL, 0=
);
+    state->BitXor_type =3D make_type("BitXor", state->operator_type, NULL, 0,
+        "BitXor");
     if (!state->BitXor_type) return 0;
     state->BitXor_singleton =3D PyType_GenericNew((PyTypeObject
                                                 *)state->BitXor_type, NULL,
                                                 NULL);
     if (!state->BitXor_singleton) return 0;
-    state->BitAnd_type =3D make_type("BitAnd", state->operator_type, NULL, 0=
);
+    state->BitAnd_type =3D make_type("BitAnd", state->operator_type, NULL, 0,
+        "BitAnd");
     if (!state->BitAnd_type) return 0;
     state->BitAnd_singleton =3D PyType_GenericNew((PyTypeObject
                                                 *)state->BitAnd_type, NULL,
                                                 NULL);
     if (!state->BitAnd_singleton) return 0;
-    state->FloorDiv_type =3D make_type("FloorDiv", state->operator_type, NUL=
L, 0);
+    state->FloorDiv_type =3D make_type("FloorDiv", state->operator_type, NUL=
L, 0,
+        "FloorDiv");
     if (!state->FloorDiv_type) return 0;
     state->FloorDiv_singleton =3D PyType_GenericNew((PyTypeObject
                                                   *)state->FloorDiv_type, NU=
LL,
                                                   NULL);
     if (!state->FloorDiv_singleton) return 0;
-    state->unaryop_type =3D make_type("unaryop", state->AST_type, NULL, 0);
+    state->unaryop_type =3D make_type("unaryop", state->AST_type, NULL, 0,
+        "unaryop =3D Invert | Not | UAdd | USub");
     if (!state->unaryop_type) return 0;
     if (!add_attributes(state->unaryop_type, NULL, 0)) return 0;
-    state->Invert_type =3D make_type("Invert", state->unaryop_type, NULL, 0);
+    state->Invert_type =3D make_type("Invert", state->unaryop_type, NULL, 0,
+        "Invert");
     if (!state->Invert_type) return 0;
     state->Invert_singleton =3D PyType_GenericNew((PyTypeObject
                                                 *)state->Invert_type, NULL,
                                                 NULL);
     if (!state->Invert_singleton) return 0;
-    state->Not_type =3D make_type("Not", state->unaryop_type, NULL, 0);
+    state->Not_type =3D make_type("Not", state->unaryop_type, NULL, 0,
+        "Not");
     if (!state->Not_type) return 0;
     state->Not_singleton =3D PyType_GenericNew((PyTypeObject *)state->Not_ty=
pe,
                                              NULL, NULL);
     if (!state->Not_singleton) return 0;
-    state->UAdd_type =3D make_type("UAdd", state->unaryop_type, NULL, 0);
+    state->UAdd_type =3D make_type("UAdd", state->unaryop_type, NULL, 0,
+        "UAdd");
     if (!state->UAdd_type) return 0;
     state->UAdd_singleton =3D PyType_GenericNew((PyTypeObject *)state->UAdd_=
type,
                                               NULL, NULL);
     if (!state->UAdd_singleton) return 0;
-    state->USub_type =3D make_type("USub", state->unaryop_type, NULL, 0);
+    state->USub_type =3D make_type("USub", state->unaryop_type, NULL, 0,
+        "USub");
     if (!state->USub_type) return 0;
     state->USub_singleton =3D PyType_GenericNew((PyTypeObject *)state->USub_=
type,
                                               NULL, NULL);
     if (!state->USub_singleton) return 0;
-    state->cmpop_type =3D make_type("cmpop", state->AST_type, NULL, 0);
+    state->cmpop_type =3D make_type("cmpop", state->AST_type, NULL, 0,
+        "cmpop =3D Eq | NotEq | Lt | LtE | Gt | GtE | Is | IsNot | In | NotI=
n");
     if (!state->cmpop_type) return 0;
     if (!add_attributes(state->cmpop_type, NULL, 0)) return 0;
-    state->Eq_type =3D make_type("Eq", state->cmpop_type, NULL, 0);
+    state->Eq_type =3D make_type("Eq", state->cmpop_type, NULL, 0,
+        "Eq");
     if (!state->Eq_type) return 0;
     state->Eq_singleton =3D PyType_GenericNew((PyTypeObject *)state->Eq_type,
                                             NULL, NULL);
     if (!state->Eq_singleton) return 0;
-    state->NotEq_type =3D make_type("NotEq", state->cmpop_type, NULL, 0);
+    state->NotEq_type =3D make_type("NotEq", state->cmpop_type, NULL, 0,
+        "NotEq");
     if (!state->NotEq_type) return 0;
     state->NotEq_singleton =3D PyType_GenericNew((PyTypeObject
                                                *)state->NotEq_type, NULL, NU=
LL);
     if (!state->NotEq_singleton) return 0;
-    state->Lt_type =3D make_type("Lt", state->cmpop_type, NULL, 0);
+    state->Lt_type =3D make_type("Lt", state->cmpop_type, NULL, 0,
+        "Lt");
     if (!state->Lt_type) return 0;
     state->Lt_singleton =3D PyType_GenericNew((PyTypeObject *)state->Lt_type,
                                             NULL, NULL);
     if (!state->Lt_singleton) return 0;
-    state->LtE_type =3D make_type("LtE", state->cmpop_type, NULL, 0);
+    state->LtE_type =3D make_type("LtE", state->cmpop_type, NULL, 0,
+        "LtE");
     if (!state->LtE_type) return 0;
     state->LtE_singleton =3D PyType_GenericNew((PyTypeObject *)state->LtE_ty=
pe,
                                              NULL, NULL);
     if (!state->LtE_singleton) return 0;
-    state->Gt_type =3D make_type("Gt", state->cmpop_type, NULL, 0);
+    state->Gt_type =3D make_type("Gt", state->cmpop_type, NULL, 0,
+        "Gt");
     if (!state->Gt_type) return 0;
     state->Gt_singleton =3D PyType_GenericNew((PyTypeObject *)state->Gt_type,
                                             NULL, NULL);
     if (!state->Gt_singleton) return 0;
-    state->GtE_type =3D make_type("GtE", state->cmpop_type, NULL, 0);
+    state->GtE_type =3D make_type("GtE", state->cmpop_type, NULL, 0,
+        "GtE");
     if (!state->GtE_type) return 0;
     state->GtE_singleton =3D PyType_GenericNew((PyTypeObject *)state->GtE_ty=
pe,
                                              NULL, NULL);
     if (!state->GtE_singleton) return 0;
-    state->Is_type =3D make_type("Is", state->cmpop_type, NULL, 0);
+    state->Is_type =3D make_type("Is", state->cmpop_type, NULL, 0,
+        "Is");
     if (!state->Is_type) return 0;
     state->Is_singleton =3D PyType_GenericNew((PyTypeObject *)state->Is_type,
                                             NULL, NULL);
     if (!state->Is_singleton) return 0;
-    state->IsNot_type =3D make_type("IsNot", state->cmpop_type, NULL, 0);
+    state->IsNot_type =3D make_type("IsNot", state->cmpop_type, NULL, 0,
+        "IsNot");
     if (!state->IsNot_type) return 0;
     state->IsNot_singleton =3D PyType_GenericNew((PyTypeObject
                                                *)state->IsNot_type, NULL, NU=
LL);
     if (!state->IsNot_singleton) return 0;
-    state->In_type =3D make_type("In", state->cmpop_type, NULL, 0);
+    state->In_type =3D make_type("In", state->cmpop_type, NULL, 0,
+        "In");
     if (!state->In_type) return 0;
     state->In_singleton =3D PyType_GenericNew((PyTypeObject *)state->In_type,
                                             NULL, NULL);
     if (!state->In_singleton) return 0;
-    state->NotIn_type =3D make_type("NotIn", state->cmpop_type, NULL, 0);
+    state->NotIn_type =3D make_type("NotIn", state->cmpop_type, NULL, 0,
+        "NotIn");
     if (!state->NotIn_type) return 0;
     state->NotIn_singleton =3D PyType_GenericNew((PyTypeObject
                                                *)state->NotIn_type, NULL, NU=
LL);
     if (!state->NotIn_singleton) return 0;
     state->comprehension_type =3D make_type("comprehension", state->AST_type,
-                                          comprehension_fields, 4);
+                                          comprehension_fields, 4,
+        "comprehension(expr target, expr iter, expr* ifs, int is_async)");
     if (!state->comprehension_type) return 0;
     if (!add_attributes(state->comprehension_type, NULL, 0)) return 0;
     state->excepthandler_type =3D make_type("excepthandler", state->AST_type,
-                                          NULL, 0);
+                                          NULL, 0,
+        "excepthandler =3D ExceptHandler(expr? type, identifier? name, stmt*=
 body)");
     if (!state->excepthandler_type) return 0;
     if (!add_attributes(state->excepthandler_type, excepthandler_attributes,
         4)) return 0;
@@ -1831,21 +1981,24 @@ static int init_types(void)
         return 0;
     state->ExceptHandler_type =3D make_type("ExceptHandler",
                                           state->excepthandler_type,
-                                          ExceptHandler_fields, 3);
+                                          ExceptHandler_fields, 3,
+        "ExceptHandler(expr? type, identifier? name, stmt* body)");
     if (!state->ExceptHandler_type) return 0;
     if (PyObject_SetAttr(state->ExceptHandler_type, state->type, Py_None) =
=3D=3D -1)
         return 0;
     if (PyObject_SetAttr(state->ExceptHandler_type, state->name, Py_None) =
=3D=3D -1)
         return 0;
     state->arguments_type =3D make_type("arguments", state->AST_type,
-                                      arguments_fields, 7);
+                                      arguments_fields, 7,
+        "arguments(arg* posonlyargs, arg* args, arg? vararg, arg* kwonlyargs=
, expr* kw_defaults, arg? kwarg, expr* defaults)");
     if (!state->arguments_type) return 0;
     if (!add_attributes(state->arguments_type, NULL, 0)) return 0;
     if (PyObject_SetAttr(state->arguments_type, state->vararg, Py_None) =3D=
=3D -1)
         return 0;
     if (PyObject_SetAttr(state->arguments_type, state->kwarg, Py_None) =3D=
=3D -1)
         return 0;
-    state->arg_type =3D make_type("arg", state->AST_type, arg_fields, 3);
+    state->arg_type =3D make_type("arg", state->AST_type, arg_fields, 3,
+        "arg(identifier arg, expr? annotation, string? type_comment)");
     if (!state->arg_type) return 0;
     if (!add_attributes(state->arg_type, arg_attributes, 4)) return 0;
     if (PyObject_SetAttr(state->arg_type, state->annotation, Py_None) =3D=3D=
 -1)
@@ -1857,29 +2010,33 @@ static int init_types(void)
     if (PyObject_SetAttr(state->arg_type, state->end_col_offset, Py_None) =
=3D=3D -1)
         return 0;
     state->keyword_type =3D make_type("keyword", state->AST_type, keyword_fi=
elds,
-                                    2);
+                                    2,
+        "keyword(identifier? arg, expr value)");
     if (!state->keyword_type) return 0;
     if (!add_attributes(state->keyword_type, NULL, 0)) return 0;
     if (PyObject_SetAttr(state->keyword_type, state->arg, Py_None) =3D=3D -1)
         return 0;
-    state->alias_type =3D make_type("alias", state->AST_type, alias_fields, =
2);
+    state->alias_type =3D make_type("alias", state->AST_type, alias_fields, =
2,
+        "alias(identifier name, identifier? asname)");
     if (!state->alias_type) return 0;
     if (!add_attributes(state->alias_type, NULL, 0)) return 0;
     if (PyObject_SetAttr(state->alias_type, state->asname, Py_None) =3D=3D -=
1)
         return 0;
     state->withitem_type =3D make_type("withitem", state->AST_type,
-                                     withitem_fields, 2);
+                                     withitem_fields, 2,
+        "withitem(expr context_expr, expr? optional_vars)");
     if (!state->withitem_type) return 0;
     if (!add_attributes(state->withitem_type, NULL, 0)) return 0;
     if (PyObject_SetAttr(state->withitem_type, state->optional_vars, Py_None)
         =3D=3D -1)
         return 0;
-    state->type_ignore_type =3D make_type("type_ignore", state->AST_type, NU=
LL,
-                                        0);
+    state->type_ignore_type =3D make_type("type_ignore", state->AST_type, NU=
LL, 0,
+        "type_ignore =3D TypeIgnore(int lineno, string tag)");
     if (!state->type_ignore_type) return 0;
     if (!add_attributes(state->type_ignore_type, NULL, 0)) return 0;
     state->TypeIgnore_type =3D make_type("TypeIgnore", state->type_ignore_ty=
pe,
-                                       TypeIgnore_fields, 2);
+                                       TypeIgnore_fields, 2,
+        "TypeIgnore(int lineno, string tag)");
     if (!state->TypeIgnore_type) return 0;
     state->initialized =3D 1;
     return 1;



More information about the Python-checkins mailing list