python 3.9 and 3.10 compatibility

This commit is contained in:
Gilles Boccon-Gibod
2025-08-30 12:07:08 -07:00
parent 116dc9b319
commit 91ba2f61f1
4 changed files with 33 additions and 10 deletions

View File

@@ -500,6 +500,22 @@ class OpenIntEnum(enum.IntEnum):
return obj
# -----------------------------------------------------------------------------
class CompatibleIntFlag(enum.IntFlag):
"""
Subclass of `enum.IntFlag` with a `composite_name` property that behaves like the
`name` property of the `enum.IntFlag` implementation for python vesions >= 3.11
"""
@property
def composite_name(self) -> str:
return '|'.join(
name
for flag in self.__class__
if self.value & flag.value and (name := flag.name) is not None
)
# -----------------------------------------------------------------------------
class ByteSerializable(Protocol):
"""