add getnewargs_ex to Enum, fix pickling (#663)

This commit is contained in:
benedikt-bartscher
2025-03-30 23:48:58 +02:00
committed by GitHub
parent 6a65ca94bc
commit 08e8a68893
2 changed files with 16 additions and 0 deletions

View File

@@ -132,6 +132,9 @@ class Enum(IntEnum if TYPE_CHECKING else int, metaclass=EnumType):
super().__setattr__(self, "value", value)
return self
def __getnewargs_ex__(self) -> Tuple[Tuple[()], Dict[str, Any]]:
return (), {"name": self.name, "value": self.value}
def __str__(self) -> str:
return self.name or "None"