Make the repr of SingleKey shorter

This commit is contained in:
Kovid Goyal
2021-11-22 20:40:42 +05:30
parent a824a45602
commit e97afb3433
2 changed files with 19 additions and 11 deletions

View File

@@ -52,6 +52,14 @@ class SingleKey(NamedTuple):
is_native: bool = False
key: int = -1
def __repr__(self) -> str:
kwds = []
for i, f in enumerate(self._fields):
val = self[i]
if val != self._field_defaults[f]:
kwds.append(f'{f}={val!r}')
return 'SingleKey(' + ', '.join(kwds) + ')'
class MouseEvent(NamedTuple):
button: int = 0