@@ -218,30 +218,24 @@ def validate_grouping(grouping, schema, full_schema=None, path=()):
218
218
Validate that the provided grouping conforms to the provided schema.
219
219
If not, raise a SchemaValidationError
220
220
"""
221
- # Inline full_schema logic for fewer function stack frames
222
221
if full_schema is None :
223
222
full_schema = schema
224
223
225
- typ = type (schema )
226
- if typ is tuple or typ is list :
224
+ if isinstance (schema , (tuple , list )):
227
225
SchemaTypeValidationError .check (grouping , full_schema , path , (tuple , list ))
228
226
SchemaLengthValidationError .check (grouping , full_schema , path , len (schema ))
229
- # Use manual index for fewer packs/unpacks
230
- for idx in range (len (schema )):
231
- g = grouping [idx ]
232
- s = schema [idx ]
233
- validate_grouping (g , s , full_schema = full_schema , path = path + (idx ,))
234
- elif typ is dict :
227
+
228
+ for i , (g , s ) in enumerate (zip (grouping , schema )):
229
+ validate_grouping (g , s , full_schema = full_schema , path = path + (i ,))
230
+ elif isinstance (schema , dict ):
235
231
SchemaTypeValidationError .check (grouping , full_schema , path , dict )
236
232
SchemaKeysValidationError .check (grouping , full_schema , path , set (schema ))
237
- # Avoid repeated dict.keys() conversion by iterating schema keys directly
238
233
for k in schema :
239
234
validate_grouping (
240
235
grouping [k ], schema [k ], full_schema = full_schema , path = path + (k ,)
241
236
)
242
237
else :
243
- # Scalar case, nothing to check
244
- return
238
+ pass
245
239
246
240
247
241
def update_args_group (g , triggered ):
0 commit comments