From 73a1ce80a60cb6d2fbea820421be5776b433c294 Mon Sep 17 00:00:00 2001 From: Kenny Yi Date: Thu, 7 Nov 2024 11:37:53 -0800 Subject: [PATCH] fix lint for python 3.8 --- azureai/get_statsig_user.py | 4 ++-- azureai/model_client.py | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/azureai/get_statsig_user.py b/azureai/get_statsig_user.py index af42212..27a1b9c 100644 --- a/azureai/get_statsig_user.py +++ b/azureai/get_statsig_user.py @@ -6,5 +6,5 @@ def get_statsig_user(user: Optional[StatsigUser] = None) -> StatsigUser: if user is not None: user.custom_ids["sdk_type"] = "azureai-python" return user - else: - return StatsigUser(custom_ids={"sdk_type": "azureai-python"}) + + return StatsigUser(custom_ids={"sdk_type": "azureai-python"}) diff --git a/azureai/model_client.py b/azureai/model_client.py index f96c1ae..5589a5e 100644 --- a/azureai/model_client.py +++ b/azureai/model_client.py @@ -1,6 +1,6 @@ import time -from typing import Dict, Iterable, List, Optional, Union, Callable +from typing import Dict, Iterable, List, Optional, Union, Callable, TypeVar from azure.ai.inference import ChatCompletionsClient, EmbeddingsClient from azure.ai.inference.models._models import ( ChatRequestMessage, @@ -15,6 +15,7 @@ from statsig import statsig, StatsigUser, StatsigEvent from .get_statsig_user import get_statsig_user +T = TypeVar( "T" ) class InvokeContext: invoke_time: float @@ -139,7 +140,7 @@ def task(): return res return self.handle_errors(task=task, fallback=None) - def handle_errors[T](self, task: Callable[[], T], fallback: T) -> T: + def handle_errors(self, task: Callable[[], T], fallback: T) -> T: try: return task() except HttpResponseError as e: