11from typing import (
22 Any ,
3- Dict ,
4- List ,
5- Optional ,
6- Type ,
73 TypeVar ,
84 Union ,
95 cast ,
2016BaseModelType = TypeVar ("BaseModelType" , bound = BaseModel )
2117
2218# Define a type alias for JSON-serializable values
23- JSONValue = Union [Dict [str , Any ], List [Any ], str , int , float , bool , None ]
19+ JSONValue = Union [dict [str , Any ], list [Any ], str , int , float , bool , None ]
2420JSON_VARIANT = JSON ().with_variant (JSONB , "postgresql" )
2521
2622
@@ -44,11 +40,9 @@ class PydanticJSONB(types.TypeDecorator): # type: ignore
4440
4541 def __init__ (
4642 self ,
47- model_class : Union [
48- Type [BaseModelType ],
49- Type [List [BaseModelType ]],
50- Type [Dict [str , BaseModelType ]],
51- ],
43+ model_class : type [BaseModelType ]
44+ | type [list [BaseModelType ]]
45+ | type [dict [str , BaseModelType ]],
5246 * args : Any ,
5347 ** kwargs : Any ,
5448 ):
@@ -80,7 +74,7 @@ def process_bind_param(self, value: Any, dialect: Any) -> JSONValue: # noqa: AN
8074
8175 def process_result_value (
8276 self , value : Any , dialect : Any
83- ) -> Optional [ Union [ BaseModelType , List [BaseModelType ], Dict [str , BaseModelType ]]] : # noqa: ANN401, ARG002, ANN001
77+ ) -> BaseModelType | list [BaseModelType ] | dict [str , BaseModelType ] | None : # noqa: ANN401, ARG002, ANN001
8478 if value is None :
8579 return None
8680 if isinstance (value , dict ):
0 commit comments