Skip to content

Commit 37c7804

Browse files
committed
fix: resolve Python 3.9 compatibility in remaining integration test files
- Fix union type syntax in test_smoke.py - Fix union type syntax in test_watermark_image_file_integration.py - Fix union type syntax in test_live_api.py - Add proper typing imports to all integration test files - Replace isinstance with tuple syntax for Python 3.9 compatibility This completes Python 3.9 compatibility across the entire codebase. All tests now collect and import correctly.
1 parent 28a4d27 commit 37c7804

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

tests/integration/test_live_api.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,31 @@
55

66
from __future__ import annotations
77

8+
from typing import Optional, Union
9+
810
import pytest
911

1012
from nutrient_dws import NutrientClient
1113

1214
try:
1315
from . import integration_config # type: ignore[attr-defined]
1416

15-
API_KEY: str | None = integration_config.API_KEY
16-
BASE_URL: str | None = getattr(integration_config, "BASE_URL", None)
17+
API_KEY: Optional[str] = integration_config.API_KEY
18+
BASE_URL: Optional[str] = getattr(integration_config, "BASE_URL", None)
1719
TIMEOUT: int = getattr(integration_config, "TIMEOUT", 60)
1820
except ImportError:
1921
API_KEY = None
2022
BASE_URL = None
2123
TIMEOUT = 60
2224

2325

24-
def assert_is_pdf(file_path_or_bytes: str | bytes) -> None:
26+
def assert_is_pdf(file_path_or_bytes: Union[str, bytes]) -> None:
2527
"""Assert that a file or bytes is a valid PDF.
2628
2729
Args:
2830
file_path_or_bytes: Path to file or bytes content to check.
2931
"""
30-
if isinstance(file_path_or_bytes, str | bytes):
32+
if isinstance(file_path_or_bytes, (str, bytes)):
3133
if isinstance(file_path_or_bytes, str):
3234
with open(file_path_or_bytes, "rb") as f:
3335
content = f.read(8)

tests/integration/test_smoke.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
"""Basic smoke test to validate integration test setup."""
22

3+
from typing import Optional
4+
35
import pytest
46

57
from nutrient_dws import NutrientClient
68

79
# Type annotation for mypy
8-
API_KEY: str | None = None
10+
API_KEY: Optional[str] = None
911

1012
try:
1113
from . import integration_config # type: ignore[attr-defined]

tests/integration/test_watermark_image_file_integration.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import os
44
from pathlib import Path
5+
from typing import Optional, Union
56

67
import pytest
78

@@ -10,16 +11,16 @@
1011
try:
1112
from . import integration_config # type: ignore[attr-defined]
1213

13-
API_KEY: str | None = integration_config.API_KEY
14-
BASE_URL: str | None = getattr(integration_config, "BASE_URL", None)
14+
API_KEY: Optional[str] = integration_config.API_KEY
15+
BASE_URL: Optional[str] = getattr(integration_config, "BASE_URL", None)
1516
TIMEOUT: int = getattr(integration_config, "TIMEOUT", 60)
1617
except ImportError:
1718
API_KEY = None
1819
BASE_URL = None
1920
TIMEOUT = 60
2021

2122

22-
def assert_is_pdf(file_path_or_bytes: str | bytes) -> None:
23+
def assert_is_pdf(file_path_or_bytes: Union[str, bytes]) -> None:
2324
"""Assert that a file or bytes is a valid PDF."""
2425
if isinstance(file_path_or_bytes, str):
2526
with open(file_path_or_bytes, "rb") as f:

0 commit comments

Comments
 (0)