Skip to content

Commit be40603

Browse files
committed
Add get_version(with_dev=...) argument
1 parent 2c54781 commit be40603

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

message_ix_models/util/sdmx.py

+15-6
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
from genno import Computer, Key
3232
from sdmx.message import StructureMessage
3333

34-
from message_ix_models.types import KeyLike, MaintainableArtefactArgs
34+
from message_ix_models.types import KeyLike
3535

3636
# TODO Use "from typing import Self" once Python 3.11 is the minimum supported
3737
Self = TypeVar("Self", bound="AnnotationsMixIn")
@@ -169,6 +169,8 @@ def __init__(
169169
# Used only for creation
170170
replace: bool = False,
171171
cs_urn: list[str] = [],
172+
# Others
173+
**ma_kwargs,
172174
):
173175
import pint
174176
from sdmx.model.common import Annotation
@@ -217,7 +219,6 @@ def __init__(
217219
anno.append(Annotation(id="file-path", text=str(_path)))
218220

219221
# Default properties for maintainable artefacts
220-
ma_kwargs: "MaintainableArtefactArgs" = dict()
221222
ma_kwargs.setdefault("maintainer", read("IIASA_ECE:AGENCIES")["IIASA_ECE"])
222223
ma_kwargs.setdefault("is_external_reference", False)
223224
ma_kwargs.setdefault("is_final", False)
@@ -566,8 +567,7 @@ def get_cl(name: str, context: Optional["Context"] = None) -> "common.Codelist":
566567
id=f"CL_{id_}",
567568
name=f"Codes for message-ix-models concept {name!r}",
568569
maintainer=as_["IIASA_ECE"],
569-
# FIXME remove str() once sdmx1 > 2.21.1 can handle Version
570-
version=str(get_version()),
570+
version=get_version(with_dev=False),
571571
is_external_reference=False,
572572
is_final=True,
573573
)
@@ -695,12 +695,21 @@ def get_concept(string: str, *, cs_urn: tuple[str, ...] = tuple()) -> "common.Co
695695
raise ValueError(string)
696696

697697

698-
def get_version() -> str:
698+
@cache
699+
def get_version(with_dev: Optional[bool] = True) -> str:
699700
"""Return a :class:`sdmx.model.common.Version` for :mod:`message_ix_models`.
700701
701702
.. todo:: Remove :py:`str(...)` once sdmx1 > 2.21.1 can handle Version.
703+
704+
Parameters
705+
----------
706+
with_dev : bool
707+
If :any:`True`, include the dev version part, e.g. "2025.3.12.dev123". If not,
708+
exclude.
702709
"""
703-
return str(common.Version(version(__package__.split(".")[0]).split("+")[0]))
710+
tmp, *_ = version(__package__.split(".")[0]).partition("+" if with_dev else ".dev")
711+
712+
return str(common.Version(tmp))
704713

705714

706715
def make_enum(urn, base=URNLookupEnum):

0 commit comments

Comments
 (0)