File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change 5
5
This is an internal API not covered by versioning policy.
6
6
"""
7
7
import dataclasses
8
+ import typing as t
8
9
from operator import attrgetter
9
10
11
+ if t .TYPE_CHECKING :
12
+ from _typeshed import DataclassInstance
13
+
10
14
11
15
class SkipDefaultFieldsReprMixin :
12
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 :
76
80
"""Omit default fields in object representation."""
77
81
nodef_f_vals = (
78
82
(f .name , attrgetter (f .name )(self ))
79
- for f in dataclasses .fields (self ) # type:ignore
83
+ for f in dataclasses .fields (self )
80
84
if attrgetter (f .name )(self ) != f .default
81
85
)
82
86
You can’t perform that action at this time.
0 commit comments