File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -685,7 +685,7 @@ def __init__(
685685 table = getattr (cls , "__table__" , None )
686686 if table is not None :
687687 # Attach Literal-based value constraints at the database level
688- for field_name , field in get_model_fields (cls ).items ():
688+ for field_name , field in get_model_fields (cls ).items (): # type: ignore
689689 annotation = getattr (field , "annotation" , None )
690690 literal_info = get_literal_annotation_info (annotation )
691691 if literal_info is None :
@@ -700,7 +700,7 @@ def __init__(
700700 elif base_type is bool :
701701 coerced_values = tuple (bool (v ) for v in values )
702702 else :
703- coerced_values = tuple (str (v ) for v in values )
703+ coerced_values = tuple (str (v ) for v in values ) # type: ignore
704704 constraint_name = f"ck_{ table .name } _{ field_name } _literal"
705705 constraint = CheckConstraint (
706706 column .in_ (coerced_values ),
Original file line number Diff line number Diff line change 1- from typing import Annotated , Literal , Union
1+ from typing import Annotated , Literal
22
33import pytest
44from sqlalchemy import text
@@ -332,7 +332,7 @@ def test_literal_optional_and_union_constraints(clear_sqlmodel):
332332 class Model (SQLModel , table = True ):
333333 id : int | None = Field (default = None , primary_key = True )
334334 opt_str : Literal ["x" , "y" ] | None = None
335- union_int : Union [ Literal [10 , 20 ], None ] = None
335+ union_int : Literal [10 , 20 ] | None = None
336336
337337 engine = create_engine ("sqlite://" )
338338 SQLModel .metadata .create_all (engine )
You can’t perform that action at this time.
0 commit comments