Skip to content

Commit

Permalink
Work around _typing.get_origin signature
Browse files Browse the repository at this point in the history
  • Loading branch information
pchanial committed Sep 20, 2023
1 parent 1d2f7a7 commit e1cc7ed
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions typer/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,18 @@
from pathlib import Path
from traceback import FrameSummary, StackSummary
from types import TracebackType
from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Type, Union
from typing import (
Any,
Callable,
Dict,
List,
Optional,
Sequence,
Tuple,
Type,
Union,
cast,
)
from uuid import UUID

import click
Expand Down Expand Up @@ -779,7 +790,8 @@ def get_click_type(
case_sensitive=parameter_info.case_sensitive,
)

origin = get_origin(annotation)
# we cast to the return type of typing.origin. _typing.get_origin has another signature.
origin = cast(Union[Any, None], get_origin(annotation))
args = get_args(annotation)
if origin is Literal:
return click.Choice(
Expand Down

0 comments on commit e1cc7ed

Please sign in to comment.