From 6848915883b3d6f58c205900261c277f0a224cdf Mon Sep 17 00:00:00 2001 From: Masen Furer Date: Fri, 14 Feb 2025 17:10:01 -0800 Subject: [PATCH] Update rx.get_upload_url signature to accept Var[str] (#4826) * Update rx.get_upload_url signature to accept Var[str] * Add py.typed Fix #4806 --- reflex/components/core/upload.py | 4 ++-- reflex/components/core/upload.pyi | 2 +- reflex/py.typed | 0 3 files changed, 3 insertions(+), 3 deletions(-) create mode 100644 reflex/py.typed diff --git a/reflex/components/core/upload.py b/reflex/components/core/upload.py index 6c86d3c44..682fd45a9 100644 --- a/reflex/components/core/upload.py +++ b/reflex/components/core/upload.py @@ -147,7 +147,7 @@ uploaded_files_url_prefix = Var( ).to(str) -def get_upload_url(file_path: str) -> Var[str]: +def get_upload_url(file_path: str | Var[str]) -> Var[str]: """Get the URL of an uploaded file. Args: @@ -158,7 +158,7 @@ def get_upload_url(file_path: str) -> Var[str]: """ Upload.is_used = True - return uploaded_files_url_prefix + "/" + file_path + return Var.create(f"{uploaded_files_url_prefix}/{file_path}") def _on_drop_spec(files: Var) -> Tuple[Var[Any]]: diff --git a/reflex/components/core/upload.pyi b/reflex/components/core/upload.pyi index d1ddceb4d..7c918bee8 100644 --- a/reflex/components/core/upload.pyi +++ b/reflex/components/core/upload.pyi @@ -35,7 +35,7 @@ uploaded_files_url_prefix = Var( ), ).to(str) -def get_upload_url(file_path: str) -> Var[str]: ... +def get_upload_url(file_path: str | Var[str]) -> Var[str]: ... class UploadFilesProvider(Component): @overload diff --git a/reflex/py.typed b/reflex/py.typed new file mode 100644 index 000000000..e69de29bb