Skip to content

Commit 84b575c

Browse files
committed
lints
1 parent 1282e43 commit 84b575c

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

shiny/input_handler.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,12 @@ def _(value: Any, name: ResolvedId, session: Session) -> Any:
227227

228228
restore_ctx_dir = Path(restore_ctx.dir)
229229

230+
def cleanup_tempdir(tempdir_root: tempfile.TemporaryDirectory[str]):
231+
@session.on_ended
232+
def _():
233+
# Cleanup the temporary directory after the session ends
234+
tempdir_root.cleanup()
235+
230236
for f in value_list:
231237
assert f["datapath"] is not None and isinstance(f["datapath"], str)
232238

@@ -238,7 +244,7 @@ def _(value: Any, name: ResolvedId, session: Session) -> Any:
238244
# Copy the original file to a new temp dir, so that a restored session can't
239245
# modify the original.
240246
tempdir_root = tempfile.TemporaryDirectory()
241-
session.on_ended(lambda: tempdir_root.cleanup())
247+
cleanup_tempdir(tempdir_root)
242248

243249
tempdir = Path(tempdir_root.name) / rand_hex(12)
244250
tempdir.mkdir(parents=True, exist_ok=True)

shiny/ui/_input_file.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,10 @@ def input_file(
102102
restored_obj["type"].append(file.get("type", None))
103103
restored_obj["datapath"].append(file.get("datapath", None))
104104
restored_value = to_json_str(restored_obj)
105-
except:
105+
except Exception:
106106
warnings.warn(
107-
f"Error while restoring file input value for `{resolved_id}`. Resetting to `None`."
107+
f"Error while restoring file input value for `{resolved_id}`. Resetting to `None`.",
108+
stacklevel=1,
108109
)
109110

110111
btn_file = span(

tests/playwright/ai_generated_apps/bookmark/input_file/test_input_file_express_bookmarking.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import pytest
21
from playwright.sync_api import FilePayload, Page
32

43
from shiny.playwright import controller

0 commit comments

Comments
 (0)