Skip to content

Commit

Permalink
Add __repr__ to ParamsDict class (apache#25305)
Browse files Browse the repository at this point in the history
  • Loading branch information
dgabidullin committed Aug 11, 2022
1 parent 955d690 commit f418a5f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions airflow/models/param.py
Expand Up @@ -147,6 +147,9 @@ def __delitem__(self, v: str) -> None:
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
Expand Down
4 changes: 4 additions & 0 deletions tests/models/test_param.py
Expand Up @@ -193,6 +193,10 @@ def test_update(self):
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
Expand Down

0 comments on commit f418a5f

Please sign in to comment.