diff --git a/CHANGES.rst b/CHANGES.rst index 0e9038756..da49089cd 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,6 +5,8 @@ Version 3.x.x Unreleased +- Display :class:`~wtforms.Flags` values in their repr + Version 3.1.0 ------------- diff --git a/src/wtforms/fields/core.py b/src/wtforms/fields/core.py index 9f6fd57d1..2aba50083 100644 --- a/src/wtforms/fields/core.py +++ b/src/wtforms/fields/core.py @@ -420,7 +420,11 @@ def __contains__(self, name): return getattr(self, name) def __repr__(self): - flags = (name for name in dir(self) if not name.startswith("_")) + flags = ( + f"{name}={getattr(self, name)}" + for name in dir(self) + if not name.startswith("_") + ) return "" % ", ".join(flags) diff --git a/tests/fields/test_flags.py b/tests/fields/test_flags.py index 76dc96b57..ebd02c38b 100644 --- a/tests/fields/test_flags.py +++ b/tests/fields/test_flags.py @@ -31,7 +31,7 @@ def test_unset(flags): def test_repr(flags): - assert repr(flags) == "" + assert repr(flags) == "" def test_underscore_property(flags):