File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -145,7 +145,7 @@ def _get_type_hint(
145145 res = ""
146146 args = get_args (value )
147147
148- if value is type (None ):
148+ if value is type (None ) or value is None :
149149 return "None"
150150
151151 if rx_types .is_union (value ):
@@ -425,10 +425,18 @@ def type_to_ast(typ: Any, cls: type) -> ast.expr:
425425 Returns:
426426 The AST representation of the type annotation.
427427 """
428- if typ is type (None ):
428+ if typ is type (None ) or typ is None :
429429 return ast .Name (id = "None" )
430430
431431 origin = get_origin (typ )
432+ if origin is typing .Literal :
433+ return ast .Subscript (
434+ value = ast .Name (id = "Literal" ),
435+ slice = ast .Tuple (
436+ elts = [ast .Constant (value = val ) for val in get_args (typ )], ctx = ast .Load ()
437+ ),
438+ ctx = ast .Load (),
439+ )
432440 if origin is UnionType :
433441 origin = typing .Union
434442
You can’t perform that action at this time.
0 commit comments