(self, n: ast3.ClassDef)
| 1163 | # stmt* body, |
| 1164 | # expr* decorator_list) |
| 1165 | def visit_ClassDef(self, n: ast3.ClassDef) -> ClassDef: |
| 1166 | self.class_and_function_stack.append("C") |
| 1167 | keywords = [(kw.arg, self.visit(kw.value)) for kw in n.keywords if kw.arg] |
| 1168 | |
| 1169 | # Type parameters, if using new syntax for generics (PEP 695) |
| 1170 | explicit_type_params: list[TypeParam] | None = None |
| 1171 | |
| 1172 | if sys.version_info >= (3, 12) and n.type_params: |
| 1173 | explicit_type_params = self.translate_type_params(n.type_params) |
| 1174 | |
| 1175 | cdef = ClassDef( |
| 1176 | n.name, |
| 1177 | self.as_required_block(n.body), |
| 1178 | None, |
| 1179 | self.translate_expr_list(n.bases), |
| 1180 | metaclass=dict(keywords).get("metaclass"), |
| 1181 | keywords=keywords, |
| 1182 | type_args=explicit_type_params, |
| 1183 | ) |
| 1184 | cdef.decorators = self.translate_expr_list(n.decorator_list) |
| 1185 | self.set_line(cdef, n) |
| 1186 | |
| 1187 | if self.options.include_docstrings: |
| 1188 | cdef.docstring = ast3.get_docstring(n, clean=False) |
| 1189 | cdef.column = n.col_offset |
| 1190 | cdef.end_line = n.end_lineno |
| 1191 | cdef.end_column = n.end_col_offset |
| 1192 | self.class_and_function_stack.pop() |
| 1193 | return cdef |
| 1194 | |
| 1195 | def validate_type_param(self, type_param: ast_TypeVar) -> None: |
| 1196 | incorrect_expr = find_disallowed_expression_in_annotation_scope(type_param.bound) |
nothing calls this directly
no test coverage detected