Skip to content

Commit 98d04f0

Browse files
committed
lint
1 parent b6e9594 commit 98d04f0

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

src/replicate/_client.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,25 @@
44

55
import os
66
from typing import (
7+
TYPE_CHECKING,
78
Any,
8-
AsyncIterator,
9-
Callable,
10-
Iterator,
9+
Union,
1110
Literal,
1211
Mapping,
13-
Optional,
14-
TYPE_CHECKING,
1512
TypeVar,
16-
Union,
13+
Callable,
14+
Iterator,
15+
Optional,
16+
AsyncIterator,
1717
cast,
1818
overload,
1919
)
20-
from typing_extensions import ParamSpec, Self, Unpack, override
20+
from typing_extensions import Self, Unpack, ParamSpec, override
2121

2222
import httpx
2323

24-
from replicate._utils._logs import logger
2524
from replicate.lib._files import FileEncodingStrategy
25+
from replicate._utils._logs import logger
2626
from replicate.lib._predictions_run import Model, Version, ModelVersionIdentifier
2727
from replicate.types.prediction_create_params import PredictionCreateParamsWithoutVersion
2828

@@ -82,28 +82,28 @@ def _get_api_token_from_environment() -> str | None:
8282
"""Get API token from cog current scope if available, otherwise from environment."""
8383
try:
8484
import cog # type: ignore[import-untyped, import-not-found]
85-
85+
8686
# Get the current scope - this might return None or raise an exception
8787
scope = getattr(cog, "current_scope", lambda: None)()
8888
if scope is None:
8989
return os.environ.get("REPLICATE_API_TOKEN")
90-
90+
9191
# Get the context from the scope
9292
context = getattr(scope, "context", None)
9393
if context is None:
9494
return os.environ.get("REPLICATE_API_TOKEN")
95-
95+
9696
# Get the items method and call it
9797
items_method = getattr(context, "items", None)
9898
if not callable(items_method):
9999
return os.environ.get("REPLICATE_API_TOKEN")
100-
100+
101101
# Iterate through context items looking for the API token
102102
items = cast(Iterator[tuple[Any, Any]], items_method())
103103
for key, value in items:
104104
if str(key).upper() == "REPLICATE_API_TOKEN":
105105
return str(value) if value is not None else value
106-
106+
107107
except Exception as e: # Catch all exceptions to ensure robust fallback
108108
logger.debug("Failed to retrieve API token from cog.current_scope(): %s", e)
109109

src/replicate/types/prediction_create_params.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class PredictionCreateParamsWithoutVersion(TypedDict, total=False):
3535
- you don't want to upload and host the file somewhere
3636
- you don't need to use the file again (Replicate will not store it)
3737
"""
38-
38+
3939
stream: bool
4040
"""**This field is deprecated.**
4141

tests/test_current_scope.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def test_sync_client_uses_current_scope_token(self):
149149
mock_scope.context = {"REPLICATE_API_TOKEN": "cog-token"}
150150
mock_cog = mock.MagicMock()
151151
mock_cog.current_scope.return_value = mock_scope
152-
152+
153153
# Clear environment variable to ensure we're using cog
154154
with mock.patch.dict(os.environ, {}, clear=True):
155155
with mock.patch.dict(sys.modules, {"cog": mock_cog}):
@@ -162,7 +162,7 @@ def test_async_client_uses_current_scope_token(self):
162162
mock_scope.context = {"REPLICATE_API_TOKEN": "cog-token"}
163163
mock_cog = mock.MagicMock()
164164
mock_cog.current_scope.return_value = mock_scope
165-
165+
166166
# Clear environment variable to ensure we're using cog
167167
with mock.patch.dict(os.environ, {}, clear=True):
168168
with mock.patch.dict(sys.modules, {"cog": mock_cog}):
@@ -203,7 +203,7 @@ def test_explicit_token_overrides_current_scope(self):
203203
mock_scope.context = {"REPLICATE_API_TOKEN": "cog-token"}
204204
mock_cog = mock.MagicMock()
205205
mock_cog.current_scope.return_value = mock_scope
206-
206+
207207
with mock.patch.dict(sys.modules, {"cog": mock_cog}):
208208
client = Replicate(bearer_token="explicit-token", base_url="http://test.example.com")
209209
assert client.bearer_token == "explicit-token"
@@ -214,7 +214,7 @@ def test_explicit_async_token_overrides_current_scope(self):
214214
mock_scope.context = {"REPLICATE_API_TOKEN": "cog-token"}
215215
mock_cog = mock.MagicMock()
216216
mock_cog.current_scope.return_value = mock_scope
217-
217+
218218
with mock.patch.dict(sys.modules, {"cog": mock_cog}):
219219
client = AsyncReplicate(bearer_token="explicit-token", base_url="http://test.example.com")
220-
assert client.bearer_token == "explicit-token"
220+
assert client.bearer_token == "explicit-token"

0 commit comments

Comments
 (0)