Skip to content

Commit 2e107f2

Browse files
committed
Update FileUpload migration/changelog docs
Move the compatibility code to the migration guide, and cross-link from changelog.
1 parent 8886410 commit 2e107f2

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

docs/Readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ To build the ipywidgets documentation:
55
1. Install the development version of ipywidgets with the `dev-install.sh` script in the repo root directory.
66
2. Install the Python packages for building documentation with either mamba or conda:
77
```sh
8-
conda update --file docs/environment.yml
8+
conda env update --file docs/environment.yml
99
```
1010

1111
or with `pip`:

docs/source/changelog.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,17 @@ VBox([d, s])
6767

6868
The file upload widget has been overhauled to handle multiple files in a more useful format:
6969

70-
- The `.value` attribute is now a list of dictionaries, rather than a dictionary mapping the uploaded name to the content. To retrieve the original form, use `{f["name"]: f.content.tobytes() for f in uploader.value}`.
70+
- The `.value` attribute is now a list of dictionaries, rather than a dictionary mapping the uploaded name to the content.
7171
- The contents of each uploaded file is a [memory view](https://docs.python.org/3/library/stdtypes.html#memory-views) in the `.content` key, e.g., `uploader.value[0].content`.
72-
- The `.data` attribute has been removed. To retrieve it, use `[f.content.tobytes() for f in uploader.value]`.
73-
- The `.metadata` attribute has been removed. To retrieve it, use `[{k: v for k, v in f.items() if k != "content"} for f in w.value]`.
72+
- The `.data` attribute has been removed.
73+
- The `.metadata` attribute has been removed.
74+
75+
See the [user migration guide](./user_migration_guides.md#FileUpload) for details on how to migrate your code.
7476

7577
([#2767](https://github.com/jupyter-widgets/ipywidgets/pull/2767), [#2724](https://github.com/jupyter-widgets/ipywidgets/pull/2724), [#2666](https://github.com/jupyter-widgets/ipywidgets/pull/2666), [#2480](https://github.com/jupyter-widgets/ipywidgets/issues/2480))
7678

79+
80+
7781
#### More styling options
7882

7983
Many style and layout options have been added to core widgets:

docs/source/user_migration_guides.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ be a list of dicts containing the file information. The keys of these dicts are:
2424

2525
Suggested migration: Rewrite all usage of `FileUpload` to use the new structure.
2626
If you need to support both 7.x and 8.x, you can e.g. write functions `get_file_buffer` and similar
27-
to wrap reads from the widget.
27+
to wrap reads from the widget:
28+
29+
- For the `.value` attribute, to retrieve it in the original form, use `{f["name"]: f.content.tobytes() for f in uploader.value}`.
30+
- For the `.data` attribute, use `[f.content.tobytes() for f in uploader.value]`.
31+
- For the `.metadata` attribute, use `[{k: v for k, v in f.items() if k != "content"} for f in w.value]`.
2832

2933
#### Tooltips
3034

0 commit comments

Comments
 (0)