1111
1212from exasol .toolbox .error import ToolboxError
1313from exasol .toolbox .util .version import Version
14+ from noxconfig import (
15+ PROJECT_CONFIG ,
16+ Config ,
17+ )
1418
1519_SUCCESS = 0
1620_FAILURE = 1
2024 # ATTENTION:
2125 # This file is generated by exasol/toolbox/nox/_package_version.py when using:
2226 # * either "poetry run -- nox -s project:fix"
23- # * or "poetry run -- nox version:check -- <path/version.py> --fix"
27+ # * or "poetry run -- nox version:check -- --fix"
2428 # Do not edit this file manually!
2529 # If you need to change the version, do so in the pyproject.toml, e.g. by using `poetry version X.Y.Z`.
2630 MAJOR = {major}
3236# fmt: on
3337
3438
35- def write_version_module (version : Version , path : str , exists_ok : bool = True ) -> None :
36- version_file = Path (path )
39+ def write_version_module (version : Version , version_file : Path , exists_ok : bool = True ) -> None :
3740 if version_file .exists () and not exists_ok :
3841 raise ToolboxError (f"Version file [{ version_file } ] already exists." )
3942 version_file .unlink (missing_ok = True )
@@ -50,8 +53,6 @@ def _create_parser() -> ArgumentParser:
5053 prog = "nox -s version:check --" ,
5154 formatter_class = argparse .ArgumentDefaultsHelpFormatter ,
5255 )
53- parser .add_argument ("version_module" , help = "Path to version module" )
54- parser .add_argument ("files" , nargs = "*" )
5556 parser .add_argument (
5657 "-d" ,
5758 "--debug" ,
@@ -69,23 +70,22 @@ def _create_parser() -> ArgumentParser:
6970 return parser
7071
7172
72- def _version_check (args : Namespace ) -> int :
73- module_version = Version .from_python_module (args .version_module )
74- poetry_version = Version .from_poetry ()
73+ def _version_check (args : Namespace , config : Config ) -> int :
74+ version_file = config .version_file
7575
76+ module_version = Version .from_python_module (version_file )
77+ poetry_version = Version .from_poetry ()
7678 if args .fix :
77- write_version_module (poetry_version , args .version_module )
79+ print (
80+ f"Updating version in { version_file } from { module_version } to { poetry_version } "
81+ )
82+ write_version_module (version = poetry_version , version_file = version_file )
83+ module_version = Version .from_python_module (version_file )
7884
7985 if module_version != poetry_version :
8086 print (
81- f"Version in pyproject.toml { poetry_version } and { args . version_module } { module_version } do not match!"
87+ f"Version in pyproject.toml ( { poetry_version } ) and { version_file } ( { module_version } ) do not match!"
8288 )
83- if args .fix :
84- print (
85- f"Updating version in file ({ args .version_module } ) from { module_version } to { poetry_version } "
86- )
87- return _SUCCESS
88-
8989 return _FAILURE
9090
9191 return _SUCCESS
@@ -99,5 +99,5 @@ def version_check(session: Session) -> None:
9999 """
100100 parser = _create_parser ()
101101 args = parser .parse_args (session .posargs )
102- if _version_check (args ):
102+ if _version_check (args = args , config = PROJECT_CONFIG ):
103103 session .error ()
0 commit comments