mirror of
https://github.com/tiqi-group/pydase.git
synced 2025-04-20 00:10:03 +02:00
fixing enum serialization for python 3.10
This commit is contained in:
parent
616a5cea21
commit
484b5131e9
@ -1,5 +1,6 @@
|
||||
import inspect
|
||||
import logging
|
||||
import sys
|
||||
from collections.abc import Callable
|
||||
from enum import Enum
|
||||
from typing import Any
|
||||
@ -68,6 +69,8 @@ class Serializer:
|
||||
value = obj.name
|
||||
readonly = False
|
||||
doc = obj.__doc__
|
||||
if sys.version_info < (3, 11) and doc == "An enumeration.":
|
||||
doc = None
|
||||
if type(obj).__base__.__name__ == "ColouredEnum":
|
||||
obj_type = "ColouredEnum"
|
||||
else:
|
||||
|
@ -100,6 +100,8 @@ def test_enum_serialize() -> None:
|
||||
|
||||
def test_ColouredEnum_serialize() -> None:
|
||||
class Status(ColouredEnum):
|
||||
"""Status description."""
|
||||
|
||||
PENDING = "#FFA500"
|
||||
RUNNING = "#0000FF80"
|
||||
PAUSED = "rgb(169, 169, 169)"
|
||||
@ -121,7 +123,7 @@ def test_ColouredEnum_serialize() -> None:
|
||||
"RUNNING": "#0000FF80",
|
||||
},
|
||||
"readonly": False,
|
||||
"doc": None,
|
||||
"doc": "Status description.",
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user