Skip to content

Commit bd6ceab

Browse files
tarun292facebook-github-bot
authored andcommitted
Handle str enum breaking change in python 3.11 (#2819)
Summary: Pull Request resolved: #2819 StrEnum(str, enum.Enum) is not backwards compatible starting with Python 3.11 https://tomwojcik.com/posts/2023-01-02/python-311-str-enum-breaking-change Reviewed By: Jack-Khuu Differential Revision: D55669235 fbshipit-source-id: 79236ecf7aea14f08f9bdefc81bdba49bd4bcb09
1 parent 29d7b4d commit bd6ceab

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

sdk/etrecord/_etrecord.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import json
88
import pickle
99
from dataclasses import dataclass
10-
from enum import Enum
1110
from typing import Dict, List, Optional, Union
1211
from zipfile import BadZipFile, ZipFile
1312

@@ -29,8 +28,18 @@
2928

3029
ProgramOutput = List[Value]
3130

31+
try:
32+
# breaking change introduced in python 3.11
33+
# pyre-ignore
34+
from enum import StrEnum
35+
except ImportError:
36+
from enum import Enum
3237

33-
class ETRecordReservedFileNames(str, Enum):
38+
class StrEnum(str, Enum):
39+
pass
40+
41+
42+
class ETRecordReservedFileNames(StrEnum):
3443
ETRECORD_IDENTIFIER = "ETRECORD_V0"
3544
EDGE_DIALECT_EXPORTED_PROGRAM = "edge_dialect_exported_program"
3645
ET_DIALECT_GRAPH_MODULE = "et_dialect_graph_module"

0 commit comments

Comments
 (0)