(name, arg, defaults)
| 394 | |
| 395 | # ### Helper to validate coerce elements of lists of dictionaries ### |
| 396 | def _check_keys_and_fill(name, arg, defaults): |
| 397 | def _checks(item, defaults): |
| 398 | if item is None: |
| 399 | return |
| 400 | if not isinstance(item, dict): |
| 401 | raise ValueError( |
| 402 | """ |
| 403 | Elements of the '{name}' argument to make_subplots must be dictionaries \ |
| 404 | or None. |
| 405 | Received value of type {typ}: {val}""".format( |
| 406 | name=name, typ=type(item), val=repr(item) |
| 407 | ) |
| 408 | ) |
| 409 | |
| 410 | for k in item: |
| 411 | if k not in defaults: |
| 412 | raise ValueError( |
| 413 | """ |
| 414 | Invalid key specified in an element of the '{name}' argument to \ |
| 415 | make_subplots: {k} |
| 416 | Valid keys include: {valid_keys}""".format( |
| 417 | k=repr(k), name=name, valid_keys=repr(list(defaults)) |
| 418 | ) |
| 419 | ) |
| 420 | for k, v in defaults.items(): |
| 421 | item.setdefault(k, v) |
| 422 | |
| 423 | for arg_i in arg: |
| 424 | if isinstance(arg_i, (list, tuple)): |
| 425 | # 2D list |
| 426 | for arg_ii in arg_i: |
| 427 | _checks(arg_ii, defaults) |
| 428 | elif isinstance(arg_i, dict): |
| 429 | # 1D list |
| 430 | _checks(arg_i, defaults) |
| 431 | |
| 432 | # ### specs ### |
| 433 | if specs is None: |
no test coverage detected