File tree Expand file tree Collapse file tree 2 files changed +10
-11
lines changed Expand file tree Collapse file tree 2 files changed +10
-11
lines changed Original file line number Diff line number Diff line change 66from 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)
2019from typing_extensions import Self , Unpack , ParamSpec , override
Original file line number Diff line number Diff line change 11"""Integration with cog's current_scope functionality."""
22
3- import os
43import logging
5- from typing import Iterator , Any , cast
4+ import os
5+ from typing import Any , Iterator , Optional , cast
66
77logger = 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 ()
You can’t perform that action at this time.
0 commit comments