Skip to content

Commit 7903fcb

Browse files
committed
fix: BodyType str enum for Py 3.11+
1 parent 3b004e3 commit 7903fcb

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

openapi_python_client/parser/bodies.py

+16-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from enum import Enum
1+
import sys
22
from typing import List, Tuple, Union
33

44
import attr
@@ -15,12 +15,22 @@
1515
from ..utils import get_content_type
1616
from .errors import ErrorLevel, ParseError
1717

18+
if sys.version_info >= (3, 11):
19+
from enum import StrEnum
1820

19-
class BodyType(str, Enum):
20-
JSON = "json"
21-
DATA = "data"
22-
FILES = "files"
23-
CONTENT = "content"
21+
class BodyType(StrEnum):
22+
JSON = "json"
23+
DATA = "data"
24+
FILES = "files"
25+
CONTENT = "content"
26+
else:
27+
from enum import Enum
28+
29+
class BodyType(str, Enum):
30+
JSON = "json"
31+
DATA = "data"
32+
FILES = "files"
33+
CONTENT = "content"
2434

2535

2636
@attr.define

0 commit comments

Comments
 (0)