Skip to content

Commit e5fbd99

Browse files
Apply suggestions from code review
1 parent 09253a1 commit e5fbd99

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

dash/_grouping.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -218,30 +218,24 @@ def validate_grouping(grouping, schema, full_schema=None, path=()):
218218
Validate that the provided grouping conforms to the provided schema.
219219
If not, raise a SchemaValidationError
220220
"""
221-
# Inline full_schema logic for fewer function stack frames
222221
if full_schema is None:
223222
full_schema = schema
224223

225-
typ = type(schema)
226-
if typ is tuple or typ is list:
224+
if isinstance(schema, (tuple, list)):
227225
SchemaTypeValidationError.check(grouping, full_schema, path, (tuple, list))
228226
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):
235231
SchemaTypeValidationError.check(grouping, full_schema, path, dict)
236232
SchemaKeysValidationError.check(grouping, full_schema, path, set(schema))
237-
# Avoid repeated dict.keys() conversion by iterating schema keys directly
238233
for k in schema:
239234
validate_grouping(
240235
grouping[k], schema[k], full_schema=full_schema, path=path + (k,)
241236
)
242237
else:
243-
# Scalar case, nothing to check
244-
return
238+
pass
245239

246240

247241
def update_args_group(g, triggered):

0 commit comments

Comments
 (0)