Skip to content

Commit

Permalink
Fix flag check types to reflect API changes
Browse files Browse the repository at this point in the history
  • Loading branch information
bpapillon committed Jun 27, 2024
1 parent b150e09 commit ae2dd07
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/schematic/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,17 @@ def shutdown(self) -> None:
def check_flag(
self,
flag_key: str,
company: Optional[Dict[str, str]] = None,
user: Optional[Dict[str, str]] = None,
company: Optional[Dict[str, Optional[str]]] = None,
user: Optional[Dict[str, Optional[str]]] = None,
) -> bool:
if self.offline:
return self._get_flag_default(flag_key)

try:
cache_key = (
flag_key + ":" + str(company) + ":" + str(user) if (company or user) else flag_key
flag_key + ":" + str(company) + ":" + str(user)
if (company or user)
else flag_key
)

for provider in self.flag_check_cache_providers:
Expand Down Expand Up @@ -161,7 +163,9 @@ class AsyncSchematicConfig:
class AsyncSchematic(AsyncBaseSchematic):
def __init__(self, api_key: str, config: Optional[AsyncSchematicConfig] = None):
config = config or AsyncSchematicConfig()
httpx_client = AsyncOfflineHTTPClient() if config.offline else config.httpx_client
httpx_client = (
AsyncOfflineHTTPClient() if config.offline else config.httpx_client
)

super().__init__(
api_key=api_key,
Expand Down Expand Up @@ -191,15 +195,17 @@ async def initialize(self) -> None:
async def check_flag(
self,
flag_key: str,
company: Optional[Dict[str, str]] = None,
user: Optional[Dict[str, str]] = None,
company: Optional[Dict[str, Optional[str]]] = None,
user: Optional[Dict[str, Optional[str]]] = None,
) -> bool:
if self.offline:
return self._get_flag_default(flag_key)

try:
cache_key = (
flag_key + ":" + str(company) + ":" + str(user) if (company or user) else flag_key
flag_key + ":" + str(company) + ":" + str(user)
if (company or user)
else flag_key
)

for provider in self.flag_check_cache_providers:
Expand Down

0 comments on commit ae2dd07

Please sign in to comment.