From 4969df2dc22d804d9904042d7f194bf70f38908c Mon Sep 17 00:00:00 2001 From: Masen Furer Date: Thu, 29 Aug 2024 16:00:07 -0700 Subject: [PATCH] Handle the possibility of `bytes` in watchdog 5.0 --- reflex/utils/watch.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/reflex/utils/watch.py b/reflex/utils/watch.py index 39b177695..4095ebd78 100644 --- a/reflex/utils/watch.py +++ b/reflex/utils/watch.py @@ -1,5 +1,7 @@ """General utility functions.""" +from __future__ import annotations + import contextlib import os import shutil @@ -81,7 +83,7 @@ class AssetFolderHandler(FileSystemEventHandler): if os.path.exists(dest_path): shutil.rmtree(dest_path) - def get_dest_path(self, src_path: str) -> str: + def get_dest_path(self, src_path: str | bytes) -> str: """Get public file path. Args: @@ -90,6 +92,10 @@ class AssetFolderHandler(FileSystemEventHandler): Returns: The public file path. """ + if isinstance(src_path, (bytes, bytearray)): + src_path = src_path.decode() + elif isinstance(src_path, memoryview): + src_path = src_path.tobytes().decode() return src_path.replace( str(self.root / Dirs.APP_ASSETS), str(self.root / get_web_dir() / Dirs.PUBLIC),