@@ -40,16 +40,19 @@ def _process_type(of_type: typing.Any) -> dict[str, typing.Any]: # noqa: PLR091
4040 return {"type" : "boolean" }
4141 if of_type is float :
4242 return {"type" : "number" }
43- if of_type is tox .config .types .Command :
44- return {"type" : "array" , "items" : {"#ref" : "#/definitions/command" }}
45- if of_type is tox .config .types .EnvList :
46- return {"type" : "array" , "items" : {"type" : "string" }}
43+ if of_type in {tox .config .types .Command , tox .config .types .EnvList }:
44+ return {"type" : "array" , "items" : {"$ref" : "#/definitions/subs" }}
4745 if typing .get_origin (of_type ) in {list , set }:
48- return {"type" : "array" , "items" : _process_type (typing .get_args (of_type )[0 ])}
46+ if typing .get_args (of_type )[0 ] in {str , packaging .requirements .Requirement }:
47+ return {"type" : "array" , "items" : {"$ref" : "#/definitions/subs" }}
48+ if typing .get_args (of_type )[0 ] is tox .config .types .Command :
49+ return {"type" : "array" , "items" : _process_type (typing .get_args (of_type )[0 ])}
50+ msg = f"Unknown list type: { of_type } "
51+ raise ValueError (msg )
4952 if of_type is tox .config .set_env .SetEnv :
5053 return {
5154 "type" : "object" ,
52- "additionalProperties" : {"type " : "array" , "items" : { "type" : "string" } },
55+ "additionalProperties" : {"$ref " : "#/definitions/subs" },
5356 }
5457 if typing .get_origin (of_type ) is dict :
5558 return {
@@ -93,21 +96,46 @@ def gen_schema(state: State) -> int:
9396 "env_run_base" : {"type" : "object" , "properties" : env_properties },
9497 "env_pkg_base" : {"$ref" : "#/properties/env_run_base" },
9598 "env" : {"type" : "object" , "patternProperties" : {"^.*$" : {"$ref" : "#/properties/env_run_base" }}},
99+ "legacy_tox_ini" : {"type" : "string" },
96100 },
97- "# definitions" : {
98- "command " : {
99- "oneOf " : [
101+ "definitions" : {
102+ "subs " : {
103+ "anyOf " : [
100104 {"type" : "string" },
101105 {
102106 "type" : "object" ,
103107 "properties" : {
104108 "replace" : {"type" : "string" },
105- "default" : {"type" : "array" , "items" : {"type" : "string" }},
109+ "name" : {"type" : "string" },
110+ "default" : {
111+ "oneOf" : [
112+ {"type" : "string" },
113+ {"type" : "array" , "items" : {"$ref" : "#/definitions/subs" }},
114+ ]
115+ },
106116 "extend" : {"type" : "boolean" },
107117 },
118+ "required" : ["replace" ],
119+ "additionalProperties" : False ,
120+ },
121+ {
122+ "type" : "object" ,
123+ "properties" : {
124+ "replace" : {"type" : "string" },
125+ "of" : {"type" : "array" , "items" : {"type" : "string" }},
126+ "default" : {
127+ "oneOf" : [
128+ {"type" : "string" },
129+ {"type" : "array" , "items" : {"$ref" : "#/definitions/subs" }},
130+ ]
131+ },
132+ "extend" : {"type" : "boolean" },
133+ },
134+ "required" : ["replace" , "of" ],
135+ "additionalProperties" : False ,
108136 },
109137 ],
110- }
138+ },
111139 },
112140 }
113141 print (json .dumps (json_schema , indent = 2 )) # noqa: T201
0 commit comments