Hooks into the class typechecking process to add support for dataclasses.
(ctx: ClassDefContext)
| 960 | |
| 961 | |
| 962 | def dataclass_class_maker_callback(ctx: ClassDefContext) -> bool: |
| 963 | """Hooks into the class typechecking process to add support for dataclasses.""" |
| 964 | if any(i.is_named_tuple for i in ctx.cls.info.mro): |
| 965 | ctx.api.fail("A NamedTuple cannot be a dataclass", ctx=ctx.cls.info) |
| 966 | return True |
| 967 | transformer = DataclassTransformer( |
| 968 | ctx.cls, ctx.reason, _get_transform_spec(ctx.reason), ctx.api |
| 969 | ) |
| 970 | return transformer.transform() |
| 971 | |
| 972 | |
| 973 | def _get_transform_spec(reason: Expression) -> DataclassTransformSpec: |
nothing calls this directly
no test coverage detected
searching dependent graphs…