Repository navigation
Name the calling method in opt-in accessor errors - #518
Merged
Merged
Conversation
selected_rows(df) reads the opt-in "selected" accessor under a different name, so a caller who never called selected() got an error telling them to fix selected() instead of selected_rows(). Accessors.read() and _read_accessor() now take an optional call= naming the method that was actually invoked; selected_rows() passes its own name through.
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the method-specific accessor error-message change.
No open issues 🎉
What changed in this PR
Improves opt-in accessor errors so Plotly’s selected_rows() names the method the caller used, while still recommending listen_to=["selected"].
Changes:
- Passes the calling method’s name through accessor reads.
- Preserves error messages for direct accessor calls.
- Adds regression tests for both behaviors.
| File | Description |
|---|---|
tests/unit/test_plotly_accessors.py |
Tests method-specific Plotly error messages. |
tests/unit/test_accessors.py |
Tests caller-name overrides in accessor errors. |
shinywidgets/_render_widget.py |
Supplies selected_rows() as the calling method. |
shinywidgets/_render_widget_base.py |
Forwards the caller name to accessor reads. |
shinywidgets/_accessors.py |
Uses the caller name in opt-in errors. |
Review effort: Balanced
✅ Deploy Preview for shinywidgets canceled.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
plot.selected_rows(df)reads plotly's opt-inselectedaccessor under a different name. Calling it without opting in raised an error aboutselected()— a method the caller never wrote:Before:
After:
Direct accessor reads (
plot.selected()) are unchanged.Audited every
_read_accessor()call site against the six opt-in accessors (plotly'sselected/selecting/brushing/hover, keplergl'sconfig, nglview'scamera_orientation);selected_rows()is the only public method that reads one under a different name.How
Accessors.read()andrender_widget_base._read_accessor()take an optionalcall=naming the method that was actually invoked, used only in the error text —listen_to=[...]still names the underlying accessor.selected_rows()passescall="selected_rows()".Stacked on #517.