Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [UNRELEASED]

### Updated

- Allow non-string extras in `flaglist` attributes, to support upcoming changes to `ax.automargin` in plotly.js [plotly.js#6193](https://github.com/plotly/plotly.js/pull/6193), [#3749](https://github.com/plotly/plotly.py/pull/3749)

## [5.8.0] - 2022-05-09

### Fixed
Expand Down
21 changes: 8 additions & 13 deletions packages/python/plotly/_plotly_utils/basevalidators.py
Original file line number Diff line number Diff line change
Expand Up @@ -1795,8 +1795,6 @@ def __init__(
self.extras = extras if extras is not None else []
self.array_ok = array_ok

self.all_flags = self.flags + self.extras

def description(self):

desc = (
Expand Down Expand Up @@ -1835,24 +1833,21 @@ def description(self):
return desc

def vc_scalar(self, v):
if isinstance(v, str):
v = v.strip()

if v in self.extras:
return v

if not isinstance(v, str):
return None

# To be generous we accept flags separated on plus ('+'),
# or comma (',')
# or comma (',') and we accept whitespace around the flags
split_vals = [e.strip() for e in re.split("[,+]", v)]

# Are all flags valid names?
all_flags_valid = all([f in self.all_flags for f in split_vals])

# Are any 'extras' flags present?
has_extras = any([f in self.extras for f in split_vals])

# For flaglist to be valid all flags must be valid, and if we have
# any extras present, there must be only one flag (the single extras
# flag)
is_valid = all_flags_valid and (not has_extras or len(split_vals) == 1)
if is_valid:
if all(f in self.flags for f in split_vals):
return "+".join(split_vals)
else:
return None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,45 @@
import numpy as np


EXTRAS = ["none", "all", True, False, 3]
FLAGS = ["lines", "markers", "text"]

# Fixtures
# --------
@pytest.fixture(params=[None, ["none", "all"]])
@pytest.fixture(params=[None, EXTRAS])
def validator(request):
# Validator with or without extras
return FlaglistValidator(
"prop", "parent", flags=["lines", "markers", "text"], extras=request.param
)
return FlaglistValidator("prop", "parent", flags=FLAGS, extras=request.param)


@pytest.fixture()
def validator_extra():
return FlaglistValidator(
"prop", "parent", flags=["lines", "markers", "text"], extras=["none", "all"]
)
return FlaglistValidator("prop", "parent", flags=FLAGS, extras=EXTRAS)


@pytest.fixture()
def validator_extra_aok():
return FlaglistValidator(
"prop",
"parent",
flags=["lines", "markers", "text"],
extras=["none", "all"],
flags=FLAGS,
extras=EXTRAS,
array_ok=True,
)


@pytest.fixture(
params=[
"+".join(p)
for i in range(1, 4)
for p in itertools.permutations(["lines", "markers", "text"], i)
for i in range(1, len(FLAGS) + 1)
for p in itertools.permutations(FLAGS, i)
]
)
def flaglist(request):
return request.param


@pytest.fixture(params=["none", "all"])
@pytest.fixture(params=EXTRAS)
def extra(request):
return request.param

Expand All @@ -69,7 +68,7 @@ def test_coercion(in_val, coerce_val, validator):


# ### Rejection by type ###
@pytest.mark.parametrize("val", [21, (), ["lines"], set(), {}])
@pytest.mark.parametrize("val", [(), ["lines"], set(), {}])
def test_rejection_type(val, validator):
with pytest.raises(ValueError) as validation_failure:
validator.validate_coerce(val)
Expand All @@ -79,7 +78,7 @@ def test_rejection_type(val, validator):

# ### Rejection by value ###
@pytest.mark.parametrize(
"val", ["", "line", "markers+line", "lin es", "lin es+markers"]
"val", ["", "line", "markers+line", "lin es", "lin es+markers", 21]
)
def test_rejection_val(val, validator):
with pytest.raises(ValueError) as validation_failure:
Expand Down Expand Up @@ -144,7 +143,7 @@ def test_acceptance_aok_scalarlist_flaglist(flaglist, validator_extra_aok):
[
["all", "markers", "text+markers"],
["lines", "lines+markers", "markers+lines+text"],
["all", "all", "lines+text", "none"],
["all", "all", "lines+text"] + EXTRAS,
],
)
def test_acceptance_aok_list_flaglist(val, validator_extra_aok):
Expand All @@ -158,8 +157,8 @@ def test_acceptance_aok_list_flaglist(val, validator_extra_aok):
"in_val,expected",
[
(
[" lines ", " lines + markers ", "lines ,markers"],
["lines", "lines+markers", "lines+markers"],
[" lines ", " lines + markers ", "lines ,markers", " all "],
["lines", "lines+markers", "lines+markers", "all"],
),
(np.array(["text +lines"]), np.array(["text+lines"], dtype="unicode")),
],
Expand Down
2 changes: 1 addition & 1 deletion packages/python/plotly/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def get_latest_publish_build_info(repo, branch):

url = (
r"https://circleci.com/api/v1.1/project/github/"
r"{repo}/tree/{branch}?limit=10000\&filter=completed"
r"{repo}/tree/{branch}?limit=100&filter=completed"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After I remove the \ that makes its way into the final URL but before changing the limit value, this returns:

{
  "message" : "limit must be between 0 and 100"
}

I don't know what set of jobs this was returning when the \ was there, looked recent but somehow didn't include any publish-dist jobs. 🤷 anyway now it seems to work locally.

).format(repo=repo, branch=branch)

branch_jobs = request_json(url)
Expand Down