Skip to content

Commit cb120bf

Browse files
authored
Fix mypy (#158)
mypy doesn't correctly handle try except blocks, so it's necessary to import from the correct module based on the python version.
1 parent 528a5ba commit cb120bf

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

openai/api_requestor.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import json
22
import platform
3+
import sys
34
import threading
45
import warnings
56
from json import JSONDecodeError
@@ -8,10 +9,9 @@
89

910
import requests
1011

11-
# Literal is available from Python 3.8
12-
try:
12+
if sys.version_info >= (3, 8):
1313
from typing import Literal
14-
except ImportError:
14+
else:
1515
from typing_extensions import Literal
1616

1717
import openai

0 commit comments

Comments
 (0)