Skip to content

Commit 8347763

Browse files
claude[bot]zeke
andcommitted
fix: resolve Python 3.9 compatibility and lint issues
- Replace 'str | None' syntax with 'Optional[str]' for Python 3.9 compatibility - Fix import sorting in both _client.py and cog.py - Remove unused 'cast' import from _client.py Co-authored-by: Zeke Sikelianos <[email protected]>
1 parent 4b5f45c commit 8347763

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

src/replicate/_client.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@
66
from typing import (
77
TYPE_CHECKING,
88
Any,
9-
Union,
10-
Literal,
11-
Mapping,
12-
TypeVar,
9+
AsyncIterator,
1310
Callable,
1411
Iterator,
12+
Literal,
13+
Mapping,
1514
Optional,
16-
AsyncIterator,
17-
cast,
15+
TypeVar,
16+
Union,
1817
overload,
1918
)
2019
from typing_extensions import Self, Unpack, ParamSpec, override

src/replicate/lib/cog.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
"""Integration with cog's current_scope functionality."""
22

3-
import os
43
import logging
5-
from typing import Iterator, Any, cast
4+
import os
5+
from typing import Any, Iterator, Optional, cast
66

77
logger = logging.getLogger("replicate")
88

99

10-
def get_api_token_from_current_scope() -> str | None:
10+
def get_api_token_from_current_scope() -> Optional[str]:
1111
"""Get API token from cog's current_scope if available, otherwise return None.
1212
1313
This function attempts to retrieve the API token from cog's current_scope context.
1414
It gracefully handles all errors and returns None if cog is not available or if
1515
any part of the retrieval process fails.
1616
1717
Returns:
18-
str | None: The API token from cog's current_scope, or None if not available.
18+
Optional[str]: The API token from cog's current_scope, or None if not available.
1919
"""
2020
try:
2121
import cog # type: ignore[import-untyped, import-not-found]
@@ -47,7 +47,7 @@ def get_api_token_from_current_scope() -> str | None:
4747
return None
4848

4949

50-
def get_api_token_from_environment() -> str | None:
50+
def get_api_token_from_environment() -> Optional[str]:
5151
"""Get API token from cog current scope if available, otherwise from environment."""
5252
# Try to get token from cog's current_scope first
5353
token = get_api_token_from_current_scope()

0 commit comments

Comments
 (0)