Skip to content

Commit

Permalink
resolve Literal in a python3.12 type
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianPugh committed Jul 2, 2024
1 parent 1b1e55c commit 58c1048
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cyclopts/help.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import inspect
import sys
from enum import Enum
from functools import lru_cache, partial
from inspect import isclass
Expand Down Expand Up @@ -27,6 +28,11 @@

from cyclopts.core import App

if sys.version_info >= (3, 12):
from typing import TypeAliasType
else:
TypeAliasType = None


@lru_cache(maxsize=16)
def docstring_parse(doc: str):
Expand Down Expand Up @@ -282,6 +288,8 @@ def _get_choices(type_: Type, name_transform: Callable[[str], str]) -> str:
args = get_args(type_)
if len(args) == 1 or (_origin is tuple and len(args) == 2 and args[1] is Ellipsis):
choices = get_choices(args[0])
elif TypeAliasType is not None and isinstance(type_, TypeAliasType):
choices = get_choices(type_.__value__)
return choices


Expand Down

0 comments on commit 58c1048

Please sign in to comment.