Skip to content

Commit e6dee27

Browse files
febus982claude
andcommitted
Use any() for more efficient model validation
Replaces list comprehension with any() generator expression to short-circuit on first invalid model instead of iterating all items. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 0ead23a commit e6dee27

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

sqlalchemy_bind_manager/_repository/base_repository.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ def _model_pk(self) -> str:
349349
return primary_keys[0].name
350350

351351
def _fail_if_invalid_models(self, objects: Iterable[MODEL]) -> None:
352-
if [x for x in objects if not isinstance(x, self._model)]:
352+
if any(not isinstance(x, self._model) for x in objects):
353353
raise InvalidModelError(
354354
"Cannot handle models not belonging to this repository"
355355
)

0 commit comments

Comments
 (0)