Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add __repr__ to ParamsDict class #25305

Merged
merged 3 commits into from Jul 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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