This is an automated email from the ASF dual-hosted git repository. msumit 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 df388a3d53 Add __repr__ to ParamsDict class (#25305) df388a3d53 is described below commit df388a3d5364b748993e61b522d0b68ff8b8124a Author: Sumit Maheshwari <msu...@users.noreply.github.com> AuthorDate: Wed Jul 27 12:43:27 2022 +0530 Add __repr__ to ParamsDict class (#25305) Fixes #25295 --- airflow/models/param.py | 3 +++ tests/models/test_param.py | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/airflow/models/param.py b/airflow/models/param.py index fcbe7a0f93..1179dd9fd6 100644 --- a/airflow/models/param.py +++ b/airflow/models/param.py @@ -147,6 +147,9 @@ class ParamsDict(MutableMapping[str, Any]): def __iter__(self): return iter(self.__dict) + def __repr__(self): + return repr(self.dump()) + def __setitem__(self, key: str, value: Any) -> None: """ Override for dictionary's ``setitem`` method. This method make sure that all values are of diff --git a/tests/models/test_param.py b/tests/models/test_param.py index 3529f0360c..bbd430d773 100644 --- a/tests/models/test_param.py +++ b/tests/models/test_param.py @@ -193,6 +193,10 @@ class TestParamsDict: with pytest.raises(ParamValidationError, match=r'Invalid input for param key: 1 is not'): pd.update({'key': 1}) + def test_repr(self): + pd = ParamsDict({'key': Param('value', type='string')}) + assert repr(pd) == "{'key': 'value'}" + class TestDagParamRuntime: VALUE = 42