gh-96865: [Enum] fix Flag to use CONFORM boundary (GH-97528)

This commit is contained in:
Ethan Furman 2022-10-05 15:25:55 -07:00 committed by GitHub
parent c206e53bb7
commit b44372e03c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 2 deletions

View file

@ -1269,7 +1269,7 @@ class FlagBoundary(StrEnum):
STRICT, CONFORM, EJECT, KEEP = FlagBoundary
class Flag(Enum, boundary=STRICT):
class Flag(Enum, boundary=CONFORM):
"""
Support for flags
"""

View file

@ -2927,7 +2927,7 @@ class OldTestFlag(unittest.TestCase):
self.assertEqual(bool(f.value), bool(f))
def test_boundary(self):
self.assertIs(enum.Flag._boundary_, STRICT)
self.assertIs(enum.Flag._boundary_, CONFORM)
class Iron(Flag, boundary=STRICT):
ONE = 1
TWO = 2

View file

@ -0,0 +1,9 @@
fix Flag to use boundary CONFORM
This restores previous Flag behavior of allowing flags with non-sequential values to be combined; e.g.
class Skip(Flag):
TWO = 2
EIGHT = 8
Skip.TWO | Skip.EIGHT -> <Skip.TWO|EIGHT: 10>