Skip to content

gh-118761: Use enum._simple_enum for annotationlib.Format #132031

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Lib/annotationlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
]


class Format(enum.IntEnum):
@enum._simple_enum(enum.IntEnum)
class Format:
VALUE = 1
VALUE_WITH_FAKE_GLOBALS = 2
FORWARDREF = 3
Expand Down
9 changes: 9 additions & 0 deletions Lib/test/test_annotationlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import annotationlib
import builtins
import collections
import enum
import functools
import itertools
import pickle
Expand Down Expand Up @@ -51,6 +52,14 @@ def test_enum(self):
self.assertEqual(Format.STRING.value, 4)
self.assertEqual(Format.STRING, 4)

def test_simple_enum(self):
class Format(enum.IntEnum):
VALUE = 1
VALUE_WITH_FAKE_GLOBALS = 2
FORWARDREF = 3
STRING = 4
enum._test_simple_enum(Format, annotationlib.Format)


class TestForwardRefFormat(unittest.TestCase):
def test_closure(self):
Expand Down
Loading