]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Fix pep8 issues
authorAlessio Bogon <youtux@gmail.com>
Sun, 15 Sep 2019 10:18:53 +0000 (12:18 +0200)
committerAlessio Bogon <youtux@gmail.com>
Sun, 15 Sep 2019 10:18:53 +0000 (12:18 +0200)
lib/sqlalchemy/ext/linter.py
test/ext/test_linter.py

index 3ffa83d9bbf3598dc9a86ff6b174a105f7fe5304..29d4dcb457c1ee77e0447d4d2cbfee7d6f1a6ae2 100644 (file)
@@ -2,7 +2,6 @@ import collections
 import itertools
 
 from sqlalchemy import util
-
 from sqlalchemy.sql import visitors
 from sqlalchemy.sql.expression import Select
 
@@ -17,8 +16,9 @@ def before_execute_hook(conn, clauseelement, multiparams, params):
 
 
 def find_unmatching_froms(query, start_with=None):
-    # type: (Select, Optional[FromClause]) -> Tuple[Set[FromClause], FromClause]
-    # TODO: It would be nicer to use OrderedSet, but it seems to not be too much optimize, so let's skip for now
+    # type: (Select, Optional[FromClause]) -> Tuple[Set[FromClause], FromClause]  # noqa
+    # TODO: It would be nicer to use OrderedSet, but it seems to not
+    #  be too much optimized, so let's skip for now
     froms = set(query.froms)
     if not froms:
         return None, None
@@ -97,7 +97,8 @@ def warn_for_unmatching_froms(query):
     # type: (Select) -> None
     froms, start_with = find_unmatching_froms(query)
     if froms:
-        template = '''Query\n{query}\nhas FROM elements:\n{froms}\nthat are not joined up to FROM element\n{start}'''
+        template = 'Query\n{query}\nhas FROM elements:\n{froms}\nthat ' \
+                   'are not joined up to FROM element\n{start}'''
         indent = '    '
         froms_str = '\n'.join('* {elem}'.format(elem=from_) for from_ in froms)
         message = template.format(
index b8bc76f892a831a467461d975627061ea9395e9d..e962b1fcc8264093577f2b74765a02929712e9af 100644 (file)
@@ -1,9 +1,9 @@
-from sqlalchemy import select, Integer, event, testing
+from sqlalchemy import event, Integer, select, testing
 from sqlalchemy.ext import linter
 from sqlalchemy.ext.linter import find_unmatching_froms
-from sqlalchemy.testing import fixtures, expect_warnings
-from sqlalchemy.testing.schema import Table, Column
+from sqlalchemy.testing import expect_warnings, fixtures
 from sqlalchemy.testing.mock import patch
+from sqlalchemy.testing.schema import Column, Table
 
 
 class TestFindUnmatchingFroms(fixtures.TablesTest):
@@ -105,7 +105,11 @@ class TestFindUnmatchingFroms(fixtures.TablesTest):
             assert not froms
 
     def test_disconnected_subquery(self):
-        subq = select([self.a]).where(self.a.c.col_a == self.b.c.col_b).subquery()
+        subq = (
+            select([self.a])
+            .where(self.a.c.col_a == self.b.c.col_b)
+            .subquery()
+        )
         stmt = select([self.c]).select_from(subq)
 
         froms, start = find_unmatching_froms(stmt, self.c)
@@ -117,8 +121,16 @@ class TestFindUnmatchingFroms(fixtures.TablesTest):
         assert froms == {self.c}
 
     def test_now_connect_it(self):
-        subq = select([self.a]).where(self.a.c.col_a == self.b.c.col_b).subquery()
-        stmt = select([self.c]).select_from(subq).where(self.c.c.col_c == subq.c.col_a)
+        subq = (
+            select([self.a])
+            .where(self.a.c.col_a == self.b.c.col_b)
+            .subquery()
+        )
+        stmt = (
+            select([self.c])
+            .select_from(subq)
+            .where(self.c.c.col_c == subq.c.col_a)
+        )
 
         froms, start = find_unmatching_froms(stmt)
         assert not froms
@@ -131,7 +143,10 @@ class TestFindUnmatchingFroms(fixtures.TablesTest):
         query = (
             select([self.a])
             .select_from(
-                self.a.join(self.b.join(self.c, self.b.c.col_b == self.c.c.col_c), self.a.c.col_a == self.b.c.col_b)
+                self.a.join(
+                    self.b.join(self.c, self.b.c.col_b == self.c.c.col_c),
+                    self.a.c.col_a == self.b.c.col_b,
+                )
             )
         )
         froms, start = find_unmatching_froms(query)