5555
5656
5757def _get_engine_import_validator (
58- import_name : str , engine_type : str , extra_name : t .Optional [str ] = None
58+ import_name : str , engine_type : str , extra_name : t .Optional [str ] = None , decorate : bool = True
5959) -> t .Callable :
6060 extra_name = extra_name or engine_type
6161
62- @model_validator (mode = "before" )
6362 def validate (cls : t .Any , data : t .Any ) -> t .Any :
6463 check_import = (
6564 str_to_bool (str (data .pop ("check_import" , True ))) if isinstance (data , dict ) else True
@@ -83,7 +82,7 @@ def validate(cls: t.Any, data: t.Any) -> t.Any:
8382
8483 return data
8584
86- return validate
85+ return model_validator ( mode = "before" )( validate ) if decorate else validate
8786
8887
8988class ConnectionConfig (abc .ABC , BaseConfig ):
@@ -1454,16 +1453,14 @@ def _mssql_engine_import_validator(cls, data: t.Any) -> t.Any:
14541453
14551454 import_module , extra_name = driver_configs [driver ]
14561455
1457- # Conditionally delegate to the existing _get_engine_import_validator
1458- # Create a validator for the specific driver and call its inner function
1459- validator_func = _get_engine_import_validator (import_module , driver , extra_name )
1460-
1461- # Extract the inner validate function from the decorated validator
1462- # The validator_func has a __wrapped__ attribute that contains the original function
1463- inner_validate = getattr (validator_func , "__wrapped__" , validator_func )
1456+ # Use _get_engine_import_validator with decorate=False to get the raw validation function
1457+ # This avoids the __wrapped__ issue in Python 3.9
1458+ validator_func = _get_engine_import_validator (
1459+ import_module , driver , extra_name , decorate = False
1460+ )
14641461
1465- # Call the inner validation function directly
1466- return inner_validate (cls , data )
1462+ # Call the raw validation function directly
1463+ return validator_func (cls , data )
14671464
14681465 @property
14691466 def _connection_kwargs_keys (self ) -> t .Set [str ]:
0 commit comments