Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 05dfac2

Browse files
committed
Merge pull request #32 from plotly/val-types-fix
The `val_types` key had been implicitly required, fixed.
2 parents 5299d22 + 4614c6b commit 05dfac2

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

‎plotly/graph_objs/graph_objs.py‎

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -634,24 +634,30 @@ def to_graph_objs(self, caller=True):
634634
obj = NAME_TO_CLASS[class_name]() # gets constructor
635635
if isinstance(obj, PlotlyDict):
636636
if not isinstance(self[key], dict):
637-
info_key = NAME_TO_KEY[self.__class__.__name__]
637+
try:
638+
val_types = INFO[info_key][key]['val_types']
639+
except KeyError:
640+
val_types = 'undocumented'
638641
raise exceptions.PlotlyDictValueError(
639642
obj=self,
640643
key=key,
641644
value=self[key],
642-
val_types=INFO[info_key][key]['val_types'],
645+
val_types=val_types,
643646
notes="value needs to be dictionary-like"
644647
)
645648
for k, v in self.pop(key).items():
646649
obj[k] = v # finish up momentarily...
647650
else: # if not PlotlyDict, it MUST be a PlotlyList
648651
if not isinstance(self[key], list):
649-
info_key = NAME_TO_KEY[self.__class__.__name__]
652+
try:
653+
val_types = INFO[info_key][key]['val_types']
654+
except KeyError:
655+
val_types = 'undocumented'
650656
raise exceptions.PlotlyDictValueError( # TODO!!!
651657
obj=self,
652658
key=key,
653659
value=self[key],
654-
val_types=INFO[info_key][key]['val_types'],
660+
val_types=val_types,
655661
notes="value needs to be list-like"
656662
)
657663
obj += self.pop(key)
@@ -695,11 +701,15 @@ def validate(self, caller=True): # TODO: validate values too?
695701
if 'type' not in INFO[obj_key][key]:
696702
continue # TODO: 'type' may not be documented yet!
697703
if INFO[obj_key][key]['type'] == 'object':
704+
try:
705+
val_types = INFO[obj_key][key]['val_types']
706+
except KeyError:
707+
val_types = 'undocumented'
698708
raise exceptions.PlotlyDictValueError(
699709
obj=self,
700710
key=key,
701711
value=val,
702-
val_types=INFO[obj_key][key]['val_types']
712+
val_types=val_types
703713
)
704714
else:
705715
matching_objects = [obj for obj in INFO if key in INFO[obj]]

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /