Skip to content

Commit 256b00c

Browse files
committed
improve help of literals
1 parent 7e1fa69 commit 256b00c

File tree

1 file changed

+9
-0
lines changed
  • openglider/glider/parametric/table/base

1 file changed

+9
-0
lines changed

openglider/glider/parametric/table/base/dto.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import abc
44
import types
5+
import typing
56
from typing import Any, ClassVar, Generic, Self, TypeVar
67

78
from openglider.utils.dataclass import BaseModel
@@ -74,6 +75,14 @@ def _get_type_string(type_: type | None) -> str:
7475
names.append(subtype.__name__)
7576

7677
return " | ".join(names)
78+
elif typing.get_origin(type_) == typing.Literal:
79+
args = [
80+
f"'{x}'" if isinstance(x, str) else x
81+
for x in
82+
typing.get_args(type_)
83+
]
84+
85+
return " | ".join(args)
7786
else:
7887
return type_.__name__
7988

0 commit comments

Comments
 (0)