diff --git a/airflow/serialization/pydantic/dataset.py b/airflow/serialization/pydantic/dataset.py index 096bda6ddd5d3..07d6b3bf88a2e 100644 --- a/airflow/serialization/pydantic/dataset.py +++ b/airflow/serialization/pydantic/dataset.py @@ -32,7 +32,6 @@ class Config: """Make sure it deals automatically with SQLAlchemy ORM classes.""" from_attributes = True - orm_mode = True # Pydantic 1.x compatibility. class TaskOutletDatasetReferencePydantic(BaseModelPydantic): @@ -48,7 +47,6 @@ class Config: """Make sure it deals automatically with SQLAlchemy ORM classes.""" from_attributes = True - orm_mode = True # Pydantic 1.x compatibility. class DatasetPydantic(BaseModelPydantic): @@ -68,7 +66,6 @@ class Config: """Make sure it deals automatically with SQLAlchemy ORM classes.""" from_attributes = True - orm_mode = True # Pydantic 1.x compatibility. class DatasetEventPydantic(BaseModelPydantic): @@ -87,4 +84,3 @@ class Config: """Make sure it deals automatically with SQLAlchemy ORM classes.""" from_attributes = True - orm_mode = True # Pydantic 1.x compatibility. diff --git a/airflow/serialization/pydantic/job.py b/airflow/serialization/pydantic/job.py index 27c8ad8ca7496..5b0e961e04153 100644 --- a/airflow/serialization/pydantic/job.py +++ b/airflow/serialization/pydantic/job.py @@ -50,4 +50,3 @@ class Config: """Make sure it deals automatically with SQLAlchemy ORM classes.""" from_attributes = True - orm_mode = True # Pydantic 1.x compatibility. diff --git a/airflow/serialization/pydantic/taskinstance.py b/airflow/serialization/pydantic/taskinstance.py index 71d8ba576f11c..0bca3505cd8a1 100644 --- a/airflow/serialization/pydantic/taskinstance.py +++ b/airflow/serialization/pydantic/taskinstance.py @@ -61,7 +61,6 @@ class Config: """Make sure it deals automatically with SQLAlchemy ORM classes.""" from_attributes = True - orm_mode = True # Pydantic 1.x compatibility. def xcom_pull( self, diff --git a/airflow/serialization/serialized_objects.py b/airflow/serialization/serialized_objects.py index 67d08b7a94fd8..8e74788a7ae7a 100644 --- a/airflow/serialization/serialized_objects.py +++ b/airflow/serialization/serialized_objects.py @@ -485,10 +485,7 @@ def serialize( elif use_pydantic_models and _ENABLE_AIP_44: def _pydantic_model_dump(model_cls: type[BaseModel], var: Any) -> dict[str, Any]: - try: - return model_cls.model_validate(var).model_dump() # type: ignore[attr-defined] - except AttributeError: # Pydantic 1.x compatibility. - return model_cls.from_orm(var).dict() # type: ignore[attr-defined] + return model_cls.model_validate(var).model_dump(mode="json") if isinstance(var, Job): return cls._encode(_pydantic_model_dump(JobPydantic, var), type_=DAT.BASE_JOB)