File tree Expand file tree Collapse file tree 2 files changed +8
-7
lines changed Expand file tree Collapse file tree 2 files changed +8
-7
lines changed Original file line number Diff line number Diff line change 1
- from enum import StrEnum , auto
1
+ from enum import Enum
2
+ from typing import Union
2
3
3
4
import typer
4
5
from typer .testing import CliRunner
@@ -84,12 +85,12 @@ class TestAnnotatedOptionAcceptsOptionalValue:
84
85
def test_enum (self ):
85
86
app = typer .Typer ()
86
87
87
- class OptEnum (StrEnum ):
88
- val1 = auto ()
89
- val2 = auto ()
88
+ class OptEnum (str , Enum ):
89
+ val1 = "val1"
90
+ val2 = "val2"
90
91
91
92
@app .command ()
92
- def cmd (opt : Annotated [bool | OptEnum , typer .Option ()] = OptEnum .val1 ):
93
+ def cmd (opt : Annotated [Union [ bool , OptEnum ] , typer .Option ()] = OptEnum .val1 ):
93
94
if opt is False :
94
95
print ("False" )
95
96
elif opt is True :
@@ -121,7 +122,7 @@ def test_int(self):
121
122
app = typer .Typer ()
122
123
123
124
@app .command ()
124
- def cmd (opt : Annotated [bool | int , typer .Option ()] = 1 ):
125
+ def cmd (opt : Annotated [Union [ bool , int ] , typer .Option ()] = 1 ):
125
126
print (opt )
126
127
127
128
result = runner .invoke (app )
Original file line number Diff line number Diff line change @@ -929,7 +929,7 @@ def get_click_param(
929
929
else :
930
930
annotation = str
931
931
main_type = annotation
932
- secondary_type : type [ bool ] | None = None
932
+ secondary_type : Union [ Type [ bool ], None ] = None
933
933
is_list = False
934
934
is_tuple = False
935
935
parameter_type : Any = None
You can’t perform that action at this time.
0 commit comments