From 0cc2abcd30649c15e9c6e5700db0919169b04e8f Mon Sep 17 00:00:00 2001 From: "David P. Kleinschmidt" Date: Fri, 25 Jul 2025 11:25:08 -0400 Subject: [PATCH] Use backwards-compatible union type syntax in Python client (#6277) --- python-client/wmill/wmill/s3_reader.py | 6 +++--- python-client/wmill/wmill/s3_types.py | 7 +++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/python-client/wmill/wmill/s3_reader.py b/python-client/wmill/wmill/s3_reader.py index 557bc9d200..6ff93db8ef 100644 --- a/python-client/wmill/wmill/s3_reader.py +++ b/python-client/wmill/wmill/s3_reader.py @@ -1,11 +1,11 @@ from io import BufferedReader, BytesIO -from json import JSONDecodeError +from typing import Optional, Union import httpx class S3BufferedReader(BufferedReader): - def __init__(self, workspace: str, windmill_client: httpx.Client, file_key: str, s3_resource_path: str | None, storage: str | None): + def __init__(self, workspace: str, windmill_client: httpx.Client, file_key: str, s3_resource_path: Optional[str], storage: Optional[str]): params = { "file_key": file_key, } @@ -61,7 +61,7 @@ class S3BufferedReader(BufferedReader): self._context_manager.__exit__(*args) -def bytes_generator(buffered_reader: BufferedReader | BytesIO): +def bytes_generator(buffered_reader: Union[BufferedReader, BytesIO]): while True: byte = buffered_reader.read(50 * 1024) if not byte: diff --git a/python-client/wmill/wmill/s3_types.py b/python-client/wmill/wmill/s3_types.py index b1736db9e9..5778eda021 100644 --- a/python-client/wmill/wmill/s3_types.py +++ b/python-client/wmill/wmill/s3_types.py @@ -1,7 +1,10 @@ +from typing import Optional + + class S3Object(dict): s3: str - storage: str | None - presigned: str | None + storage: Optional[str] + presigned: Optional[str] def __getattr__(self, attr): return self[attr]