We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 09d3384 commit e90f185Copy full SHA for e90f185
libvcs/utils/subprocess.py
@@ -41,6 +41,7 @@
41
import dataclasses
42
import subprocess
43
import sys
44
+from operator import attrgetter
45
from typing import (
46
IO,
47
Any,
@@ -351,6 +352,22 @@ def run(
351
352
check=check,
353
)
354
355
+ def __repr__(self):
356
+ """Skip defaults.
357
+
358
+ Credit: Pietro Oldrati, 2022-05-08, Unlicense
359
360
+ See also: https://stackoverflow.com/a/72161437/1396928
361
+ """
362
+ nodef_f_vals = (
363
+ (f.name, attrgetter(f.name)(self))
364
+ for f in dataclasses.fields(self)
365
+ if attrgetter(f.name)(self) != f.default
366
+ )
367
368
+ nodef_f_repr = ",".join(f"{name}={value}" for name, value in nodef_f_vals)
369
+ return f"{self.__class__.__name__}({nodef_f_repr})"
370
371
372
#
373
# Composable mixins
0 commit comments