From 007c3c98b89f43f3ba35902668b71bbf58a669dd Mon Sep 17 00:00:00 2001 From: Konsta Vesterinen Date: Tue, 17 Mar 2015 12:28:41 +0200 Subject: [PATCH] Refactor table setting --- sqlalchemy_utils/functions/orm.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sqlalchemy_utils/functions/orm.py b/sqlalchemy_utils/functions/orm.py index 859f7b2..a19d415 100644 --- a/sqlalchemy_utils/functions/orm.py +++ b/sqlalchemy_utils/functions/orm.py @@ -70,10 +70,10 @@ def get_class_by_table(base, table, data=None): :param data: Data row to determine the class in polymorphic scenarios :return: Declarative class or None. """ - found_classes = set() - for c in base._decl_class_registry.values(): - if hasattr(c, '__table__') and c.__table__ is table: - found_classes.add(c) + found_classes = set( + c for c in base._decl_class_registry.values() + if hasattr(c, '__table__') and c.__table__ is table + ) if len(found_classes) > 1: if not data: raise ValueError(