Skip to content

Commit 0dbfe91

Browse files
Yilei Yangfacebook-github-bot
authored andcommitted
Migrate (str Enum) classes to StrEnum310.
Summary: This preserves these enum's __format__ behavior when upgrading from 3.10 to 3.12. See [our wiki](https://www.internalfb.com/wiki/Python/Upgrades/3.12/#str-enum-classes-inherit) for more information. This diff was generated by searching usages, filtering out directories that have been on 3.12, and: ``` buck run fbcode//python/libcst:libcst -- codemod py310_str_enum.Py310StrEnumCommand [FILES...] pyautotargets [FILES...] ``` Then manually reverted unrelated build dependency changes (`autodeps[12]` could gain a `--restrict_to_dep=//python/migrations/py310:py310` flag, that would be extremely useful for LSCs.) Reviewed By: itamaro Differential Revision: D72270904 fbshipit-source-id: a1e6bbff80d4902de3d26b6afd72f1fb05837f18
1 parent 4c6a884 commit 0dbfe91

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

torchtnt/utils/data/iterators.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,14 @@
2929
Union,
3030
)
3131

32+
from python.migrations.py310 import StrEnum310
33+
3234
try:
3335
# pyre-ignore[21]: Could not find name `StrEnum` in `enum`
3436
from enum import StrEnum
3537
except ImportError:
36-
from enum import Enum
3738

38-
class StrEnum(str, Enum):
39+
class StrEnum(StrEnum310):
3940
pass
4041

4142

0 commit comments

Comments
 (0)