Skip to content

Commit 8008e49

Browse files
Add type hints to Image component documentation (#1229)
If the source of the image is from the PIL package, the type hint must be "Image.Image". It is easy to mistake it for simply "Image" which results in the following error: TypeError: Unsupported type <module 'PIL.Image'>. This simple type hint on the documentation resolves any confusion.
1 parent 46da8f3 commit 8008e49

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

docs/library/media/image.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ import requests
4141

4242

4343
class ImageState(rx.State):
44-
url = f"https://picsum.photos/id/1/200/300"
45-
image = Image.open(requests.get(url, stream=True).raw)
44+
url: str = f"https://picsum.photos/id/1/200/300"
45+
image: Image.Image = Image.open(requests.get(url, stream=True).raw)
4646

4747

4848
def image_pil_example():
@@ -59,4 +59,4 @@ A cv2 image must be converted to a PIL image to be passed directly to `rx.image`
5959
```md alert info
6060
# How to let your user upload an image
6161
To let a user upload an image to your app check out the [upload docs]({library.forms.upload.path}).
62-
```
62+
```

0 commit comments

Comments
 (0)