Skip to content

Commit c84eb10

Browse files
BommeCopilot
andauthored
Extract duplicate DILL_VERSION checks to private function and add 0.3.9 support (#2)
* Initial plan * Extract DILL_VERSION check to private function and add 0.3.9 support Co-authored-by: Bomme <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]>
1 parent d4e52de commit c84eb10

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/datasets/utils/_dill.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,16 @@ def proxy(func):
9898
return proxy
9999

100100

101+
def _is_supported_dill_version():
102+
"""Check if the current dill version is in the supported range."""
103+
return config.DILL_VERSION.release[:3] in [
104+
version.parse("0.3.6").release,
105+
version.parse("0.3.7").release,
106+
version.parse("0.3.8").release,
107+
version.parse("0.3.9").release,
108+
]
109+
110+
101111
def dump(obj, file):
102112
"""Pickle an object to a file."""
103113
Pickler(file, recurse=True).dump(obj)
@@ -115,11 +125,7 @@ def dumps(obj):
115125
def log(pickler, msg):
116126
dill._dill.log.info(msg)
117127

118-
elif config.DILL_VERSION.release[:3] in [
119-
version.parse("0.3.6").release,
120-
version.parse("0.3.7").release,
121-
version.parse("0.3.8").release,
122-
]:
128+
elif _is_supported_dill_version():
123129

124130
def log(pickler, msg):
125131
dill._dill.logger.trace(pickler, msg)
@@ -312,11 +318,7 @@ def _save_code(pickler, obj):
312318
dill._dill.log.info("# Co")
313319
return
314320

315-
elif config.DILL_VERSION.release[:3] in [
316-
version.parse("0.3.6").release,
317-
version.parse("0.3.7").release,
318-
version.parse("0.3.8").release,
319-
]:
321+
elif _is_supported_dill_version():
320322
# From: https://github.com/uqfoundation/dill/blob/dill-0.3.6/dill/_dill.py#L1104
321323
@pklregister(CodeType)
322324
def save_code(pickler, obj):

0 commit comments

Comments
 (0)