-
Notifications
You must be signed in to change notification settings - Fork 945
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
Drop support for Mapping types as Selection options #2679
Drop support for Mapping types as Selection options #2679
Conversation
Thanks! Currently, the I think we can probably cut more code from |
That's a good point, let's specify the type even more. |
|
e84be23
to
f8347f5
Compare
There is no reasonable traitlet supertype that includes general Python iterables, as far as I can see. For instance, the following currently works: import numpy as np
options = np.array(['hello', 'world'])
widgets.Dropdown(options=options) As far as I can tell, no refinement of |
I think some of the entries in |
23c6b56
to
db67be3
Compare
For the |
Ah yes, you're completely right, sorry. Maybe we should introduce a deprecation ahead of 8? |
Actually, since For instance, unless I'm missing something, the following is broken: import ipywidgets.widgets.widget_selection as iws
s2 = iws._MultipleSelection(options={'a': 52, 'b': 62}, value=[62]) This works on master, but fails on your branch. AFAICT, on your branch, Happy to look into this together -- I've found the logic in |
Somewhat unexpectedly, for a dictionary
This means that, for someone who's not paid attention to the deprecation warning and still has a dict, their widget won't crash -- it'll just behave really unexpectedly: the dropdown entries will be the same, but the values will just be ignored. I think this is going to be really surprising. We can either:
|
I'm fine with this, say for one more version. |
Thanks @pbugnion for investigating this further.
It looks like it does yes. We should be able to catch that in the tests though. In the long run we'll probably want to drop support for mutable types for
This could be a good compromise in the meantime. |
Just to be clear here - we are talking about dropping support for mapping types, not mutable types. |
@jtpio - what is the current status of this PR? |
It was changed back to a "WIP" to check the points raised by @pbugnion above and see if they can be covered in the tests too:
|
db67be3
to
a498a2d
Compare
We can indeed see that with a from ipywidgets import SelectMultiple
options = {'a': 'Apples', 'o': 'Oranges', 'p': 'Pears'}
select = SelectMultiple(
options=options,
description='Fruits'
)
select Which gives back the list of keys as values: We might then want to drop support for |
This would at least make the change more visible instead of silently converting the |
We can also follow this approach and be explicit about the types being accepted. For example with Edit: although we might want to keep support for the |
a498a2d
to
4e2b528
Compare
4e2b528
to
28877f9
Compare
The last commit implements the ideas mentioned above:
|
Great, thank you! I'll review this in the next couple of days. |
This amends the documentation for the multi-range slider to include spaces after commas, following PEP8.
0b4abe3
to
5a73074
Compare
I added a couple of tests to verify the behaviour when setting RTD is failing because of #2768, but the rest looks good. I'm going to merge this. Thank you! |
Thanks @pbugnion! |
Fixes #1958.
Continuation of #2130.
Breaking change
Mapping
types when constructing a newDropdown
.