Skip to content

Commit 9bef014

Browse files
authored
make sure dataclasses.dataclass is not hard-rewritten
1 parent e4eeb55 commit 9bef014

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

python/exacting/core.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
import dataclasses
21
from typing import TYPE_CHECKING, Callable, Type, TypeVar
32

3+
import dataclasses
44
from dataclasses import asdict, dataclass, is_dataclass
55

6-
if TYPE_CHECKING:
7-
from dataclasses import _DataclassT
8-
96
from .dc import get_etypes_for_dc
107

118
T = TypeVar("T", bound=Type)
@@ -71,11 +68,14 @@ def wrapper(t):
7168
setattr(x, "__init__", init)
7269
return x
7370

74-
setattr(dataclasses, "dataclass", new)
71+
return new
7572

7673

77-
_patch()
78-
exact = dataclasses.dataclass
74+
# sneaky trick
75+
if TYPE_CHECKING:
76+
exact = dataclasses.dataclass
77+
else:
78+
exact = _patch()
7979

8080

8181
class Exact:

0 commit comments

Comments
 (0)