Middle — Senior
Determining the program output during model initialization
livecode
Task condition
It is necessary to find out what value will be obtained after creating an instance of the TaskData class using the task_data dictionary.
from pydantic import Field, BaseModel
task_data = {
'flight_id': 5,
'flight_number': 'abc123'
}
class Flight(BaseModel):
flight_id: int
airline: str
flight_number: str
class SecretFlight(Flight):
secret_code: str
class PatchFlight(Flight):
airline: str = Field(default=None)
flight_number: str = Field(default=None)
class TaskData(SecretFlight, PatchFlight):
...
task_data = TaskData(**task_data)