MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _distill_params_20

Function _distill_params_20

lib/sqlalchemy/engine/_util_cy.py:71–94  ·  view source on GitHub ↗
(
    params: Optional[_CoreAnyExecuteParams],
)

Source from the content-addressed store, hash-verified

69
70
71def _distill_params_20(
72 params: Optional[_CoreAnyExecuteParams],
73) -> _CoreMultiExecuteParams:
74 if params is None:
75 return _Empty_Tuple
76 # Assume list is more likely than tuple
77 elif isinstance(params, list) or isinstance(params, tuple):
78 # collections_abc.MutableSequence # avoid abc.__instancecheck__
79 if len(params) == 0:
80 warn_deprecated(
81 "Empty parameter sequence passed to execute(). "
82 "This use is deprecated and will raise an exception in a "
83 "future SQLAlchemy release",
84 "2.1",
85 )
86 elif not _is_mapping(params[0]):
87 raise exc.ArgumentError(
88 "List argument must consist only of dictionaries"
89 )
90 return params
91 elif _is_mapping(params):
92 return [params] # type: ignore[list-item]
93 else:
94 raise exc.ArgumentError("mapping or list expected for parameters")
95
96
97# _is_mapping_or_tuple could be inlined if pure python perf is a problem

Callers 2

scalarMethod · 0.85
executeMethod · 0.85

Calls 2

warn_deprecatedFunction · 0.85
_is_mappingFunction · 0.85

Tested by

no test coverage detected