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

Function dataclass_class_maker_callback

mypy/plugins/dataclasses.py:962–970  ·  view source on GitHub ↗

Hooks into the class typechecking process to add support for dataclasses.

(ctx: ClassDefContext)

Source from the content-addressed store, hash-verified

960
961
962def 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
973def _get_transform_spec(reason: Expression) -> DataclassTransformSpec:

Callers

nothing calls this directly

Calls 5

transformMethod · 0.95
anyFunction · 0.85
_get_transform_specFunction · 0.85
failMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…