Skip to content

Commit 79b945a

Browse files
committed
fix: resolve isinstance union syntax runtime error
Fixed isinstance calls to use tuple syntax (str, bytes) instead of union syntax (str | bytes) which is not supported at runtime in Python 3.10. Added UP038 ignore rule to ruff config to prevent this regression. Union syntax in isinstance is only for type annotations, not runtime.
1 parent 813800c commit 79b945a

File tree

4 files changed

+4
-3
lines changed

4 files changed

+4
-3
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ ignore = [
8383
"D100", # Missing docstring in public module
8484
"D104", # Missing docstring in public package
8585
"D107", # Missing docstring in __init__
86+
"UP038", # Use `X | Y` in `isinstance` call instead of `(X, Y)` - not supported in Python 3.10 runtime
8687
]
8788

8889
[tool.ruff.lint.pydocstyle]

tests/integration/test_direct_api_integration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def assert_is_pdf(file_path_or_bytes: str | bytes) -> None:
2626
Args:
2727
file_path_or_bytes: Path to file or bytes content to check.
2828
"""
29-
if isinstance(file_path_or_bytes, str | bytes):
29+
if isinstance(file_path_or_bytes, (str, bytes)):
3030
if isinstance(file_path_or_bytes, str):
3131
with open(file_path_or_bytes, "rb") as f:
3232
content = f.read(8)

tests/integration/test_live_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def assert_is_pdf(file_path_or_bytes: str | bytes) -> None:
2727
Args:
2828
file_path_or_bytes: Path to file or bytes content to check.
2929
"""
30-
if isinstance(file_path_or_bytes, str | bytes):
30+
if isinstance(file_path_or_bytes, (str, bytes)):
3131
if isinstance(file_path_or_bytes, str):
3232
with open(file_path_or_bytes, "rb") as f:
3333
content = f.read(8)

tests/integration/test_new_tools_integration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def assert_is_pdf(file_path_or_bytes: str | bytes) -> None:
2828
Args:
2929
file_path_or_bytes: Path to file or bytes content to check.
3030
"""
31-
if isinstance(file_path_or_bytes, str | bytes):
31+
if isinstance(file_path_or_bytes, (str, bytes)):
3232
if isinstance(file_path_or_bytes, str):
3333
with open(file_path_or_bytes, "rb") as f:
3434
content = f.read(8)

0 commit comments

Comments
 (0)