Skip to content

Commit 58e4a01

Browse files
committed
fix(SkipDefaultFieldsReprMixin): Improve typing
1 parent 0fd17a0 commit 58e4a01

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/libvcs/_internal/dataclasses.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@
55
This is an internal API not covered by versioning policy.
66
"""
77
import dataclasses
8+
import typing as t
89
from operator import attrgetter
910

11+
if t.TYPE_CHECKING:
12+
from _typeshed import DataclassInstance
13+
1014

1115
class SkipDefaultFieldsReprMixin:
1216
r"""Skip default fields in :func:`~dataclasses.dataclass`
@@ -72,11 +76,11 @@ class SkipDefaultFieldsReprMixin:
7276
ItemWithMixin(name=Test, unit_price=2.05)
7377
"""
7478

75-
def __repr__(self) -> str:
79+
def __repr__(self: "DataclassInstance") -> str:
7680
"""Omit default fields in object representation."""
7781
nodef_f_vals = (
7882
(f.name, attrgetter(f.name)(self))
79-
for f in dataclasses.fields(self) # type:ignore
83+
for f in dataclasses.fields(self)
8084
if attrgetter(f.name)(self) != f.default
8185
)
8286

0 commit comments

Comments
 (0)