]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
switch "if not len(x)" to "if not x"
authorJonathan Ellis <jbellis@gmail.com>
Fri, 3 Aug 2007 18:28:11 +0000 (18:28 +0000)
committerJonathan Ellis <jbellis@gmail.com>
Fri, 3 Aug 2007 18:28:11 +0000 (18:28 +0000)
lib/sqlalchemy/databases/oracle.py
lib/sqlalchemy/orm/__init__.py
lib/sqlalchemy/orm/mapper.py
lib/sqlalchemy/orm/properties.py
lib/sqlalchemy/topological.py

index f183b1e4edb48e646d2a5a17d8a3334d758bc409..10b7cc962708b6a63507416cea2413808775a228 100644 (file)
@@ -427,7 +427,7 @@ class OracleDialect(ansisql.ANSIDialect):
 
             table.append_column(schema.Column(colname, coltype, nullable=nullable, *colargs))
 
-        if not len(table.columns):
+        if not table.columns:
            raise exceptions.AssertionError("Couldn't find any column information for table %s" % actual_name)
 
         c = connection.execute("""SELECT
index 5f8518783684ca9c8615d0e1b7b70a3775dcdddc..2c1a4ffc4b4cba1240348d81711a80a781be171e 100644 (file)
@@ -483,7 +483,7 @@ def compile_mappers():
     This is equivalent to calling ``compile()`` on any individual mapper.
     """
 
-    if not len(mapper_registry):
+    if not mapper_registry:
         return
     mapper_registry.values()[0].compile()
 
index 016803874a06a1ee459baf9ad1f4fe1787b028e3..4a19c3c911edc1c1abd15ba1a3f6daeb92164f84 100644 (file)
@@ -414,7 +414,7 @@ class Mapper(object):
         # may be a join or other construct
         self.tables = sqlutil.TableFinder(self.mapped_table)
 
-        if not len(self.tables):
+        if not self.tables:
             raise exceptions.InvalidRequestError("Could not find any Table objects in mapped table '%s'" % str(self.mapped_table))
 
         # determine primary key columns
@@ -538,7 +538,7 @@ class Mapper(object):
                 vis.traverse(mapper.inherit_condition)
 
         for col in (self.primary_key_argument or self.pks_by_table[self.mapped_table]):
-            if not len(col.foreign_keys):
+            if not col.foreign_keys:
                 result.setdefault(col, util.Set()).add(col)
             else:
                 for fk in col.foreign_keys:
index 1c050d4f3878f5741e0f3dc7a5219a794bcc253e..48d5b25c858cf694ae5a029c15915f161baf4785 100644 (file)
@@ -520,7 +520,7 @@ class PropertyLoader(StrategizedProperty):
                     "argument." % (str(self)))
 
     def _determine_remote_side(self):
-        if not len(self.remote_side):
+        if not self.remote_side:
             if self.direction is sync.MANYTOONE:
                 self.remote_side = util.Set(self._opposite_side)
             elif self.direction is sync.ONETOMANY or self.direction is sync.MANYTOMANY:
@@ -720,7 +720,7 @@ def deferred_load(instance, props):
 
     """
 
-    if not len(props):
+    if not props:
         return
     column_props = [p for p in props if isinstance(p, ColumnProperty)]
     callable_ = column_props[0]._get_strategy(strategies.DeferredColumnLoader).setup_loader(instance, props=column_props)
index 87efc802bae379d1476b189b42ac78cd5436a20a..ab62e662dc1b465bf8d80e3c4a6805ce4938e3d7 100644 (file)
@@ -137,7 +137,7 @@ class _EdgeCollection(object):
         if children is not None:
             for child in children:
                 self.child_to_parents[child].remove(node)
-                if not len(self.child_to_parents[child]):
+                if not self.child_to_parents[child]:
                     yield child
 
     def __len__(self):
@@ -237,7 +237,7 @@ class QueueDependencySorter(object):
         set as siblings to each other as possible.
         """
 
-        if not len(nodes):
+        if not nodes:
             return None
         # a list of all currently independent subtrees as a tuple of
         # (root_node, set_of_all_tree_nodes, set_of_all_cycle_nodes_in_tree)