This is an automated email from the ASF dual-hosted git repository. ephraimanierobi pushed a commit to branch v2-3-test in repository https://gitbox.apache.org/repos/asf/airflow.git
commit de68fd1a816598204bfb6ab8274dc0fa5cf593f2 Author: Sumit Maheshwari <[email protected]> AuthorDate: Wed Jul 27 12:43:27 2022 +0530 Add __repr__ to ParamsDict class (#25305) Fixes #25295 (cherry picked from commit df388a3d5364b748993e61b522d0b68ff8b8124a) --- 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
