Skip to content

Commit e9ba14c

Browse files
committed
move version guard to compat.py
1 parent 720d918 commit e9ba14c

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

hypothesis-python/src/hypothesis/internal/compat.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,11 @@ def dataclass_asdict(obj, *, dict_factory=dict):
205205
return _asdict_inner(obj, dict_factory)
206206

207207

208+
if sys.version_info[:2] >= (3, 12):
209+
# see issue #3812
210+
dataclass_asdict = dataclasses.asdict
211+
212+
208213
def _asdict_inner(obj, dict_factory):
209214
if dataclasses._is_dataclass_instance(obj):
210215
if dict_factory is dict:

hypothesis-python/src/hypothesis/strategies/_internal/utils.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,7 @@ def to_jsonable(obj: object) -> object:
178178
and dcs.is_dataclass(obj)
179179
and not isinstance(obj, type)
180180
):
181-
if sys.version_info[:2] < (3, 12):
182-
# see issue #3812
183-
return to_jsonable(dataclass_asdict(obj))
184-
else: # pragma: no cover
185-
return to_jsonable(dcs.asdict(obj))
181+
return to_jsonable(dataclass_asdict(obj))
186182
if attr.has(type(obj)):
187183
return to_jsonable(attr.asdict(obj, recurse=False)) # type: ignore
188184
if (pyd := sys.modules.get("pydantic")) and isinstance(obj, pyd.BaseModel):

0 commit comments

Comments
 (0)