Skip to content

Commit 6bd2bb3

Browse files
bmaranvillegvwilson
authored andcommitted
add DataValidator to autogenerated instances provided by ValidatorCache, and cleanup
1 parent 5d1ccdb commit 6bd2bb3

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

plotly/validator_cache.py

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from _plotly_utils.basevalidators import LiteralValidator
2-
from plotly.validators._data import DataValidator
32
import _plotly_utils.basevalidators as basevalidators
43
import json
54
import os.path as opath
@@ -33,9 +32,6 @@ def get_validator(parent_path, prop_name):
3332
if "." not in parent_path and prop_name == "type":
3433
# Special case for .type property of traces
3534
validator = LiteralValidator("type", parent_path, parent_path)
36-
elif parent_path == "" and prop_name == "data":
37-
# Special case for .data property of Figure
38-
validator = DataValidator
3935
else:
4036
lookup_name = None
4137
if parent_path == "layout":
@@ -47,6 +43,7 @@ def get_validator(parent_path, prop_name):
4743

4844
lookup_name = lookup_name or prop_name
4945
lookup = f"{parent_path}.{lookup_name}" if parent_path else lookup_name
46+
5047
validator_item = ValidatorCache._json_cache.get(lookup)
5148
validator_classname = validator_item["superclass"]
5249
if validator_classname in DERIVED_CLASSES:
@@ -55,20 +52,16 @@ def get_validator(parent_path, prop_name):
5552
base_item = ValidatorCache._json_cache.get(
5653
DERIVED_CLASSES[validator_classname]
5754
)
58-
validator_args = base_item["params"]
59-
validator_args.update(validator_item["params"])
55+
validator_params = base_item["params"]
56+
validator_params.update(validator_item["params"])
6057
validator_classname = base_item["superclass"]
6158
else:
62-
validator_args = validator_item["params"]
63-
59+
validator_params = validator_item["params"]
60+
validator_params["plotly_name"] = prop_name
6461
validator_class = getattr(basevalidators, validator_classname)
6562

66-
print("validator_item", key, validator_item)
67-
validator = validator_class(**validator_args)
63+
validator = validator_class(**validator_params)
6864
ValidatorCache._cache[key] = validator
6965

7066
return ValidatorCache._cache[key]
7167

72-
def generate_validator(params: dict, superclass_name: str):
73-
superclass = getattr(basevalidators, superclass_name)
74-
return superclass(**params)

0 commit comments

Comments
 (0)