forked from auracaster/bumble_mirror
python 3.9 and 3.10 compatibility
This commit is contained in:
@@ -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):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user