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 c849487 commit cf62b15Copy full SHA for cf62b15
libvcs/utils/subprocess.py
@@ -34,6 +34,7 @@
34
import dataclasses
35
import subprocess
36
import sys
37
+from operator import attrgetter
38
from typing import (
39
IO,
40
Any,
@@ -343,6 +344,22 @@ def run(
343
344
check=check,
345
)
346
347
+ def __repr__(self):
348
+ """Skip defaults.
349
+
350
+ Credit: Pietro Oldrati, 2022-05-08, Unlicense
351
352
+ See also: https://stackoverflow.com/a/72161437/1396928
353
+ """
354
+ nodef_f_vals = (
355
+ (f.name, attrgetter(f.name)(self))
356
+ for f in dataclasses.fields(self)
357
+ if attrgetter(f.name)(self) != f.default
358
+ )
359
360
+ nodef_f_repr = ",".join(f"{name}={value}" for name, value in nodef_f_vals)
361
+ return f"{self.__class__.__name__}({nodef_f_repr})"
362
363
364
#
365
# Composable mixins
0 commit comments