Skip to content

Commit 497edde

Browse files
authored
Use packaging to parse pandas version (#638)
* Use packaging to parse pandas version Replaced manual splitting of pandas version string with packaging.version.parse for more robust version parsing. Added 'packaging' to project dependencies in pyproject.toml. * Reorder import of packaging.version.parse Moved the import of 'parse' from 'packaging.version' to align with linting guidelines.
1 parent 5156d2b commit 497edde

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ dependencies = [
1717
"curies>=0.10.23",
1818
"linkml-runtime>=1.7.5",
1919
"linkml>1.7.10",
20+
"packaging>=20.0",
2021
"pandas>1.0.3",
2122
"sssom-schema==1.1.0a3",
2223
"sparqlwrapper>=2.0.0",

src/sssom/util.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
from curies import Converter, ReferenceTuple
3434
from jsonschema import ValidationError
3535
from linkml_runtime.linkml_model.types import Uriorcurie
36+
from packaging.version import parse
3637
from sssom_schema import Mapping as SSSOM_Mapping
3738
from sssom_schema import MappingSet, slots
3839
from typing_extensions import TypedDict
@@ -109,7 +110,7 @@
109110
# A value is trying to be set on a copy of a slice from a DataFrame
110111
pd.options.mode.copy_on_write = True
111112
# Get the version of pandas as a tuple of integers
112-
pandas_version = tuple(map(int, pd.__version__.split(".")))
113+
pandas_version = parse(pd.__version__).release # Returns (major, minor, micro)
113114

114115

115116
@dataclass

0 commit comments

Comments
 (0)