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

fix: Handle arrays in BooleanValidator #5464

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
camdecoster wants to merge 2 commits into main
base: main
Choose a base branch
Loading
from cam/5463/handle-arrays-booleanvalidator

Conversation

@camdecoster
Copy link
Contributor

@camdecoster camdecoster commented Jan 9, 2026
edited
Loading

Description

Update BooleanValidator to handle arrays of values.

Addresses half of #5463. The other half is addressed by #5465.

Changes

  • Handle arrays in BooleanValidator
  • Add tests

Testing

  • Be on main
  • Run the following code:
    import plotly.graph_objects as go
    pie = go.Pie(
     labels=["A", "B", "C"],
     values=[65, 15, 20],
     showlegend=[True, False, False],
    )
    fig = go.Figure([pie], go.Layout())
    fig.show()
  • Note that a ValueError is raised
  • Switch to this branch
  • Run the same code again
  • Note that chart is rendered correctly

if isinstance(val, list):
assert val == v
else:
assert val == tuple(v)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
assert val == tuple(v)
assert list(val) == v

clearer IMO

Copy link
Contributor Author

@camdecoster camdecoster Jan 13, 2026

Choose a reason for hiding this comment

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

With your change, I removed the if/else block. Clearer indeed.

invalid_els = [e for e in v if not isinstance(e, bool)]
if invalid_els:
self.raise_invalid_elements(invalid_els[:10])
v = to_scalar_or_list(v)
Copy link
Contributor

Choose a reason for hiding this comment

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

Not 100% sure whether this call to to_scalar_or_list() is necessary, but I don't think it will hurt.

camdecoster reacted with thumbs up emoji
Copy link
Contributor

@emilykl emilykl left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@emilykl emilykl emilykl approved these changes

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

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