From 8c1b00380aef1d15bac0b97fdb0993e5d169d413 Mon Sep 17 00:00:00 2001 From: Michal Vasilek Date: Wed, 21 Dec 2022 08:17:04 +0100 Subject: [PATCH] Fix mypy mypy doesn't correctly handle try except blocks, so it's necessary to import from the correct module based on the python version. --- openai/api_requestor.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openai/api_requestor.py b/openai/api_requestor.py index 99a392c148..2ae0cbe034 100644 --- a/openai/api_requestor.py +++ b/openai/api_requestor.py @@ -1,5 +1,6 @@ import json import platform +import sys import threading import warnings from json import JSONDecodeError @@ -8,10 +9,9 @@ import requests -# Literal is available from Python 3.8 -try: +if sys.version_info >= (3, 8): from typing import Literal -except ImportError: +else: from typing_extensions import Literal import openai