Skip to content

Commit 17b531c

Browse files
committed
Refactor logic to be clearer
1 parent 40166bb commit 17b531c

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

packages/python/plotly/_plotly_utils/basevalidators.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,15 @@ def is_typed_array_spec(v):
292292
return isinstance(v, dict) and "bdata" in v and "dtype" in v
293293

294294

295+
def has_skipped_key(all_parent_keys):
296+
"""
297+
Return whether any keys in the parent hierarchy are in the list of keys that
298+
are skipped for conversion to the typed array spec
299+
"""
300+
skipped_keys = ['geojson', 'layer', 'range']
301+
return any(skipped_key in all_parent_keys for skipped_key in skipped_keys)
302+
303+
295304
def is_none_or_typed_array_spec(v):
296305
return v is None or is_typed_array_spec(v)
297306

@@ -491,7 +500,7 @@ def description(self):
491500
def validate_coerce(self, v):
492501
if is_none_or_typed_array_spec(v):
493502
pass
494-
elif 'layer' in self.parent_name or 'range' in self.parent_name or 'geojson' in self.parent_name:
503+
elif has_skipped_key(self.parent_name):
495504
v = to_scalar_or_list(v)
496505
elif is_homogeneous_array(v):
497506
v = to_typed_array_spec(v)

0 commit comments

Comments
 (0)