File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99"""Script responsible for bumping the version of cookiecutter-robust-python using CalVer."""
1010
1111import sys
12+ from pathlib import Path
1213from typing import Annotated
14+ from typing import Any
1315from typing import Optional
1416
1517import typer
1618
1719from util import bump_version
1820from util import calculate_calver
19- from util import get_current_version
21+ from util import REPO_FOLDER
22+
23+
24+ try :
25+ import tomllib
26+ except ModuleNotFoundError :
27+ import tomli as tomllib
2028
2129
2230cli : typer .Typer = typer .Typer ()
@@ -45,5 +53,14 @@ def main(
4553 sys .exit (1 )
4654
4755
56+ def get_current_version () -> str :
57+ """Read current version from pyproject.toml."""
58+
59+ pyproject_path : Path = REPO_FOLDER / "pyproject.toml"
60+ with pyproject_path .open ("rb" ) as f :
61+ data : dict [str , Any ] = tomllib .load (f )
62+ return data ["project" ]["version" ]
63+
64+
4865if __name__ == "__main__" :
4966 cli ()
Original file line number Diff line number Diff line change 44# "cookiecutter",
55# "cruft",
66# "python-dotenv",
7- # "tomli>=2.0.0;python_version<'3.11'",
87# "typer",
98# ]
109# ///
@@ -257,19 +256,6 @@ def get_package_version() -> str:
257256 return result .stdout .strip ()
258257
259258
260- def get_current_version () -> str :
261- """Read current version from pyproject.toml."""
262- try :
263- import tomllib
264- except ModuleNotFoundError :
265- import tomli as tomllib
266-
267- pyproject_path : Path = REPO_FOLDER / "pyproject.toml"
268- with pyproject_path .open ("rb" ) as f :
269- data : dict [str , Any ] = tomllib .load (f )
270- return data ["project" ]["version" ]
271-
272-
273259def calculate_calver (current_version : str , micro_override : Optional [int ] = None ) -> str :
274260 """Calculate the next CalVer version.
275261
You can’t perform that action at this time.
0 commit comments