Skip to main content

typed_dict_python

No overview available.

def typed_dict_python(
name: str,
fields: dict[str, str]
) - > str

Generates a Python TypedDict class definition from a dictionary of field names and their corresponding types.

Parameters

NameTypeDescription
namestrThe name of the TypedDict class to be generated.
fieldsdict[str, str]A mapping where keys are field names and values are strings representing the Python types for those fields.

Returns

TypeDescription
strA string containing the formatted Python source code for the TypedDict class definition.