We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0fd17a0 commit 58e4a01Copy full SHA for 58e4a01
1 file changed
src/libvcs/_internal/dataclasses.py
@@ -5,8 +5,12 @@
5
This is an internal API not covered by versioning policy.
6
"""
7
import dataclasses
8
+import typing as t
9
from operator import attrgetter
10
11
+if t.TYPE_CHECKING:
12
+ from _typeshed import DataclassInstance
13
+
14
15
class SkipDefaultFieldsReprMixin:
16
r"""Skip default fields in :func:`~dataclasses.dataclass`
@@ -72,11 +76,11 @@ class SkipDefaultFieldsReprMixin:
72
76
ItemWithMixin(name=Test, unit_price=2.05)
73
77
74
78
75
- def __repr__(self) -> str:
79
+ def __repr__(self: "DataclassInstance") -> str:
80
"""Omit default fields in object representation."""
81
nodef_f_vals = (
82
(f.name, attrgetter(f.name)(self))
- for f in dataclasses.fields(self) # type:ignore
83
+ for f in dataclasses.fields(self)
84
if attrgetter(f.name)(self) != f.default
85
)
86
0 commit comments