uranusjr commented on code in PR #37855:
URL: https://github.com/apache/airflow/pull/37855#discussion_r1522058143
##########
airflow/serialization/serialized_objects.py:
##########
@@ -528,18 +546,11 @@ def serialize(
def _pydantic_model_dump(model_cls: type[BaseModel], var: Any) ->
dict[str, Any]:
return model_cls.model_validate(var).model_dump(mode="json")
# type: ignore[attr-defined]
- if isinstance(var, Job):
- return cls._encode(_pydantic_model_dump(JobPydantic, var),
type_=DAT.BASE_JOB)
- elif isinstance(var, TaskInstance):
- return cls._encode(_pydantic_model_dump(TaskInstancePydantic,
var), type_=DAT.TASK_INSTANCE)
- elif isinstance(var, DagRun):
- return cls._encode(_pydantic_model_dump(DagRunPydantic, var),
type_=DAT.DAG_RUN)
- elif isinstance(var, Dataset):
- return cls._encode(_pydantic_model_dump(DatasetPydantic, var),
type_=DAT.DATA_SET)
- elif isinstance(var, DagModel):
- return cls._encode(_pydantic_model_dump(DagModelPydantic,
var), type_=DAT.DAG_MODEL)
- elif isinstance(var, LogTemplate):
- return cls._encode(_pydantic_model_dump(LogTemplatePydantic,
var), type_=DAT.LOG_TEMPLATE)
+ if var.__class__ in _to_pydantic:
Review Comment:
```suggestion
if var.__class__ in _class_to_type:
```
Maybe name this a bit better? The additional global variable isn’t really
needed since we can just do the same on the dict.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]