This is an automated email from the ASF dual-hosted git repository.
eladkal pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 7594b7a8ee Rename `Connection.to_json_dict` to `Connection.to_dict`
(#35894)
7594b7a8ee is described below
commit 7594b7a8eecd216dbaf31fcbd958ba22a97d6709
Author: Andrey Anshin <[email protected]>
AuthorDate: Thu Nov 30 10:43:13 2023 +0400
Rename `Connection.to_json_dict` to `Connection.to_dict` (#35894)
---
airflow/models/connection.py | 11 ++++-------
airflow/serialization/serialized_objects.py | 2 +-
2 files changed, 5 insertions(+), 8 deletions(-)
diff --git a/airflow/models/connection.py b/airflow/models/connection.py
index 1e835b4673..4e8e3c7aaf 100644
--- a/airflow/models/connection.py
+++ b/airflow/models/connection.py
@@ -478,10 +478,7 @@ class Connection(Base, LoggingMixin):
raise AirflowNotFoundException(f"The conn_id `{conn_id}` isn't
defined")
- def to_dict(self) -> dict[str, Any]:
- return {"conn_id": self.conn_id, "description": self.description,
"uri": self.get_uri()}
-
- def to_json_dict(self, *, prune_empty: bool = False, validate: bool =
True) -> dict[str, Any]:
+ def to_dict(self, *, prune_empty: bool = False, validate: bool = True) ->
dict[str, Any]:
"""
Convert Connection to json-serializable dictionary.
@@ -528,6 +525,6 @@ class Connection(Base, LoggingMixin):
def as_json(self) -> str:
"""Convert Connection to JSON-string object."""
- conn = self.to_json_dict(prune_empty=True, validate=False)
- conn.pop("conn_id", None)
- return json.dumps(conn)
+ conn_repr = self.to_dict(prune_empty=True, validate=False)
+ conn_repr.pop("conn_id", None)
+ return json.dumps(conn_repr)
diff --git a/airflow/serialization/serialized_objects.py
b/airflow/serialization/serialized_objects.py
index c40d4703ee..6f0e88cae2 100644
--- a/airflow/serialization/serialized_objects.py
+++ b/airflow/serialization/serialized_objects.py
@@ -498,7 +498,7 @@ class BaseSerialization:
type_=DAT.SIMPLE_TASK_INSTANCE,
)
elif isinstance(var, Connection):
- return cls._encode(var.to_json_dict(validate=True),
type_=DAT.CONNECTION)
+ return cls._encode(var.to_dict(validate=True),
type_=DAT.CONNECTION)
elif use_pydantic_models and _ENABLE_AIP_44:
def _pydantic_model_dump(model_cls: type[BaseModel], var: Any) ->
dict[str, Any]: