Skip to content

Commit a0b46b0

Browse files
committed
Ensure ScienceState context repr has only single line
1 parent eddd52d commit a0b46b0

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

‎astropy/utils/state.py‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,13 @@ def __exit__(self, type, value, tb):
5656
self._parent._value = self._value
5757

5858
def __repr__(self):
59-
return ('<ScienceState {}: {!r}>'
60-
.format(self._parent.__name__, self._parent._value))
59+
# Ensure we have a single-line repr, just in case our
60+
# value is not something simple like a string.
61+
value_repr, lb, _ = repr(self._parent._value).partition('\n')
62+
if lb:
63+
value_repr += '...'
64+
return ('<ScienceState {}: {}>'
65+
.format(self._parent.__name__, value_repr))
6166

6267
ctx = _Context(cls, cls._value)
6368
value = cls.validate(value)

0 commit comments

Comments
 (0)