Skip to content

Commit 3a50e45

Browse files
committed
Run ruff format after adding support for arrays in subplotid validator.
1 parent 40532e4 commit 3a50e45

2 files changed

Lines changed: 16 additions & 5 deletions

File tree

_plotly_utils/basevalidators.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1740,7 +1740,9 @@ class SubplotidValidator(BaseValidator):
17401740
}
17411741
"""
17421742

1743-
def __init__(self, plotly_name, parent_name, dflt=None, regex=None, array_ok=False, **kwargs):
1743+
def __init__(
1744+
self, plotly_name, parent_name, dflt=None, regex=None, array_ok=False, **kwargs
1745+
):
17441746
if dflt is None and regex is None:
17451747
raise ValueError("One or both of regex and deflt must be specified")
17461748

@@ -1770,7 +1772,9 @@ def description(self):
17701772
subplot, of type '{base}', that may be specified as:
17711773
- the string '{base}'
17721774
optionally followed by an integer >= 1
1773-
(e.g. '{base}', '{base}1', '{base}2', '{base}3', etc.)""".format(plotly_name=self.plotly_name, base=self.base)
1775+
(e.g. '{base}', '{base}1', '{base}2', '{base}3', etc.)""".format(
1776+
plotly_name=self.plotly_name, base=self.base
1777+
)
17741778
if self.array_ok:
17751779
desc += """
17761780
- A tuple or list of the above"""

tests/test_plotly_utils/validators/test_subplotid_validator.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,19 @@
1010
def validator():
1111
return SubplotidValidator("prop", "parent", dflt="geo")
1212

13+
1314
@pytest.fixture()
1415
def validator_aok():
1516
return SubplotidValidator("prop", "parent", dflt="legend", array_ok=True)
1617

18+
1719
# Tests
1820

1921
# Array not ok (default)
2022

2123
# Acceptance
2224

25+
2326
@pytest.mark.parametrize("val", ["geo"] + ["geo%d" % i for i in range(2, 10)])
2427
def test_acceptance(val, validator):
2528
assert validator.validate_coerce(val) == val
@@ -49,11 +52,15 @@ def test_rejection_value(val, validator):
4952

5053
assert "Invalid value" in str(validation_failure.value)
5154

55+
5256
# Array ok
5357

5458
# Acceptance
5559

56-
@pytest.mark.parametrize("val", ["legend2", ["legend", "legend2"], ("legend1", "legend2")])
60+
61+
@pytest.mark.parametrize(
62+
"val", ["legend2", ["legend", "legend2"], ("legend1", "legend2")]
63+
)
5764
def test_acceptance_aok(val, validator_aok):
5865
v = validator_aok.validate_coerce(val)
5966
if isinstance(val, tuple):
@@ -80,12 +87,12 @@ def test_rejection_type_aok(val, validator_aok):
8087
"bogus", # Must begin with 'geo'
8188
"legend0", # If followed by a number the number must be > 1,
8289
["", "legend"],
83-
("bogus", "legend2")
90+
("bogus", "legend2"),
8491
],
8592
)
8693
def test_rejection_value_aok(val, validator_aok):
8794
with pytest.raises(ValueError) as validation_failure:
8895
validator_aok.validate_coerce(val)
8996

9097
failure_msg = str(validation_failure.value)
91-
assert "Invalid value" in failure_msg or "Invalid elements" in failure_msg
98+
assert "Invalid value" in failure_msg or "Invalid elements" in failure_msg

0 commit comments

Comments
 (0)