TypedDict does not show any error for mandatory fields

77 views Asked by At

I am using TypedDict, for creating some rules for my dictionary. When I am passing my one key value pair and not passing the other keys and values it is still printing the output and not showing any error to pass the mandatory fields.

from typing import TypedDict

class Persons(TypedDict):
    name : str
    year : str

person: Persons = {'name': 'Person1'}

print(person)

And getting output as

{'name': 'Person1'}

Can anyone please help me, what mistake I am making here?

0

There are 0 answers