@@ -62,7 +62,7 @@ def provision(state: State) -> int | bool:
62
62
keys = ["min_version" , "minversion" ],
63
63
of_type = Version ,
64
64
# do not include local version specifier (because it's not allowed in version spec per PEP-440)
65
- default = Version ( "4.0" ),
65
+ default = None , # type: ignore # Optional[Version] translates to object
66
66
desc = "Define the minimal tox version required to run" ,
67
67
)
68
68
state .conf .core .add_config (
@@ -72,10 +72,10 @@ def provision(state: State) -> int | bool:
72
72
desc = "Name of the virtual environment used to provision a tox." ,
73
73
)
74
74
75
- def add_tox_requires_min_version (requires : list [Requirement ]) -> list [Requirement ]:
75
+ def add_tox_requires_min_version (reqs : list [Requirement ]) -> list [Requirement ]:
76
76
min_version : Version = state .conf .core ["min_version" ]
77
- requires .append (Requirement (f"tox >= { min_version } " ))
78
- return requires
77
+ reqs .append (Requirement (f"tox{ f'>= { min_version } ' if min_version else '' } " ))
78
+ return reqs
79
79
80
80
state .conf .core .add_config (
81
81
keys = "requires" ,
@@ -113,8 +113,9 @@ def add_tox_requires_min_version(requires: list[Requirement]) -> list[Requiremen
113
113
msg = f"provisioning explicitly disabled within { sys .executable } , but { miss_msg } "
114
114
if isinstance (no_provision , str ):
115
115
msg += f" and wrote to { no_provision } "
116
+ min_version = str (next (i .specifier for i in requires if i .name == "tox" )).split ("=" )
116
117
requires_dict = {
117
- "minversion" : str ( next ( i . specifier for i in requires if i . name == "tox" )). split ( "=" )[ 1 ] ,
118
+ "minversion" : min_version [ 1 ] if len ( min_version ) >= 2 else None ,
118
119
"requires" : [str (i ) for i in requires ],
119
120
}
120
121
Path (no_provision ).write_text (json .dumps (requires_dict , indent = 4 ))
0 commit comments