]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Update black flak8 and zimports
authorFederico Caselli <cfederico87@gmail.com>
Wed, 12 May 2021 20:01:45 +0000 (22:01 +0200)
committerFederico Caselli <cfederico87@gmail.com>
Wed, 12 May 2021 20:10:19 +0000 (22:10 +0200)
Change-Id: I488c9557eda390e4a88319affd4c8813ee274f80

31 files changed:
.pre-commit-config.yaml
examples/performance/single_inserts.py
examples/space_invaders/space_invaders.py
examples/versioned_rows/versioned_update_old_row.py
lib/sqlalchemy/dialects/mssql/base.py
lib/sqlalchemy/dialects/mysql/types.py
lib/sqlalchemy/engine/interfaces.py
lib/sqlalchemy/ext/asyncio/result.py
lib/sqlalchemy/orm/interfaces.py
lib/sqlalchemy/orm/relationships.py
lib/sqlalchemy/orm/strategy_options.py
lib/sqlalchemy/sql/elements.py
lib/sqlalchemy/sql/roles.py
lib/sqlalchemy/testing/suite/test_types.py
test/dialect/oracle/test_reflection.py
test/dialect/postgresql/test_dialect.py
test/dialect/postgresql/test_types.py
test/ext/declarative/test_inheritance.py
test/ext/mypy/incremental/stubs_14/address.py
test/ext/test_orderinglist.py
test/orm/declarative/test_inheritance.py
test/orm/inheritance/test_relationship.py
test/orm/test_session.py
test/orm/test_update_delete.py
test/sql/test_cte.py
test/sql/test_deprecations.py
test/sql/test_operators.py
test/sql/test_query.py
test/sql/test_roles.py
test/sql/test_update.py
tox.ini

index c66c463ac685d90af0df8411e412942ad5347283..ae35977b9d0c027262f324fe0113c8e809331959 100644 (file)
@@ -2,17 +2,19 @@
 # See https://pre-commit.com/hooks.html for more hooks
 repos:
 -   repo: https://github.com/python/black
-    rev: 20.8b1
+    rev: 21.5b1
     hooks:
     -   id: black
 
 -   repo: https://github.com/sqlalchemyorg/zimports
-    rev: 0.3.0
+    rev: v0.4.0
     hooks:
     -   id: zimports
+        args:
+            - --keep-unused-type-checking
 
 -   repo: https://github.com/pycqa/flake8
-    rev: 3.8.4
+    rev: 3.9.2
     hooks:
     -   id: flake8
         additional_dependencies:
index 2dd87d5b69f12e4b7649c4d42642be8cb93ee93b..991d213a07b86b2accfb3508c6eda2edfbec4f21 100644 (file)
@@ -56,7 +56,7 @@ def test_orm_commit(n):
 
 @Profiler.profile
 def test_bulk_save(n):
-    """Individual INSERT/COMMIT pairs using the "bulk" API """
+    """Individual INSERT/COMMIT pairs using the "bulk" API"""
 
     for i in range(n):
         session = Session(bind=engine)
index ed6c47abc009678418abd51373bd493b73c5aa87..1690145db25f12965e58f1fd93e41f3db2237529 100644 (file)
@@ -253,7 +253,7 @@ class EnemyGlyph(Glyph):
 
 
 class ArmyGlyph(EnemyGlyph):
-    """Describe an enemy that's part of the "army". """
+    """Describe an enemy that's part of the "army"."""
 
     __mapper_args__ = {"polymorphic_identity": "army"}
 
index 5aa0f424af3bf41d0ac5d348cca1ddf9d3c877de..0da28cf42daa6c8cbe62b4f16366b395188baf39 100644 (file)
@@ -102,7 +102,7 @@ def before_flush(session, flush_context, instances):
 
 @event.listens_for(Query, "before_compile", retval=True)
 def before_compile(query):
-    """ensure all queries for VersionedStartEnd include criteria """
+    """ensure all queries for VersionedStartEnd include criteria"""
 
     for ent in query.column_descriptions:
         entity = ent["entity"]
index e59221f8344e89b2091433f7360d603ce22d7be5..750f3743bbf2e47a62ceba61f4a99ba23c3c6da0 100644 (file)
@@ -1740,7 +1740,7 @@ class MSSQLCompiler(compiler.SQLCompiler):
         )
 
     def get_select_precolumns(self, select, **kw):
-        """ MS-SQL puts TOP, it's version of LIMIT here """
+        """MS-SQL puts TOP, it's version of LIMIT here"""
 
         s = super(MSSQLCompiler, self).get_select_precolumns(select, **kw)
 
index 9a6b804b33375933eda352c805971b5a0d78c1e1..3318006e6c49382558af4a6eafcb748d43295089 100644 (file)
@@ -395,7 +395,7 @@ class BIT(sqltypes.TypeEngine):
 
 
 class TIME(sqltypes.TIME):
-    """MySQL TIME type. """
+    """MySQL TIME type."""
 
     __visit_name__ = "TIME"
 
index 47348ba767860bc76ac6215a14db7a35062581a4..0df7c954e05322502508eb1d2339d016b1d4d758 100644 (file)
@@ -14,6 +14,7 @@ from ..util import compat
 
 if compat.TYPE_CHECKING:
     from typing import Any
+
     from .url import URL
 
 
@@ -1559,8 +1560,9 @@ class Connectable(object):
     """
 
     def execute(self, object_, *multiparams, **params):
-        """Executes the given construct and returns a """
-        """:class:`_engine.CursorResult`."""
+        """Executes the given construct and returns a
+        :class:`_engine.CursorResult`.
+        """
         raise NotImplementedError()
 
     def scalar(self, object_, *multiparams, **params):
index c299dafc9916e68c6992b46871f5eff1381b0854..6899fe0a61ff653d7296f554fdc0ea3e280b11d5 100644 (file)
@@ -16,11 +16,12 @@ from ...util.concurrency import greenlet_spawn
 
 if util.TYPE_CHECKING:
     from typing import Any
-    from typing import List
-    from typing import Optional
     from typing import Int
     from typing import Iterator
+    from typing import List
     from typing import Mapping
+    from typing import Optional
+
     from ...engine.result import Row
 
 
index 6f77fd70656414d08f22c78747cc816671a51b62..68e1aa5cb0311737120187ff6624c173f9b736d7 100644 (file)
@@ -45,6 +45,7 @@ if util.TYPE_CHECKING:
     from typing import Any
     from typing import List
     from typing import Optional
+
     from .mapper import Mapper
     from .util import AliasedInsp
 
index 2ed9d859abf285e0970b238525288a6621c4b9ac..bf166e181e88c46ee582313694107468985d4d5c 100644 (file)
@@ -51,9 +51,10 @@ from ..sql.util import visit_binary_product
 
 
 if util.TYPE_CHECKING:
-    from .util import AliasedInsp
     from typing import Union
 
+    from .util import AliasedInsp
+
 
 def remote(expr):
     """Annotate a portion of a primaryjoin expression
index f61cf835d276b46fc4b5b94ccc986dc8e40c6731..60ae69176cfd0478e9c9f974bd61deafbe16736b 100644 (file)
@@ -33,8 +33,9 @@ from ..sql.base import _generative
 from ..sql.base import Generative
 
 if util.TYPE_CHECKING:
-    from .context import QueryContext
     from typing import Sequence
+
+    from .context import QueryContext
     from ..sql.elements import ColumnElement
 
 
index cdb1dbca8a5aba2ef252ba36245c82e3d0ff834a..169a6d8461d05cb018424ced1e6b5f4f5fe0ac57 100644 (file)
@@ -450,8 +450,9 @@ class ClauseElement(
         return self
 
     def _ungroup(self):
-        """Return this :class:`_expression.ClauseElement` """
-        """without any groupings."""
+        """Return this :class:`_expression.ClauseElement`
+        without any groupings.
+        """
 
         return self
 
index 7d64e83826ce67688a6c6090ed2760b9cf5d390d..8982cb159bc511fba42ca9a8c9c1ca2d9ba50a23 100644 (file)
@@ -204,7 +204,7 @@ class DMLColumnRole(SQLRole):
 
 
 class DMLSelectRole(SQLRole):
-    """A SELECT statement embedded in DML, typically INSERT from SELECT """
+    """A SELECT statement embedded in DML, typically INSERT from SELECT"""
 
     _role_name = "SELECT statement or equivalent textual object"
 
index 3e54d87a44e62de0bceb217c48ad8588114c7e8c..468a1660e25c9d7160585b5bf558ade05afc01d8 100644 (file)
@@ -49,7 +49,7 @@ class _LiteralRoundTripFixture(object):
 
     @testing.fixture
     def literal_round_trip(self, metadata, connection):
-        """test literal rendering """
+        """test literal rendering"""
 
         # for literal, we test the literal render in an INSERT
         # into a typed column.  we can then SELECT it back as its
index f9ce1a30b19abf454664bffb23d909850457e1c2..acf7d75d549785c4b3085948519ccf05263c2ac4 100644 (file)
@@ -742,7 +742,7 @@ class DBLinkReflectionTest(fixtures.TestBase):
             conn.exec_driver_sql("drop table test_table")
 
     def test_reflection(self):
-        """test the resolution of the synonym/dblink. """
+        """test the resolution of the synonym/dblink."""
         m = MetaData()
 
         t = Table(
index 1382788224750cc30f938c3708b3f60d9e67cf31..69bb41e2cee3bff090959ea81d23b4d515e5d9b7 100644 (file)
@@ -62,7 +62,7 @@ if True:
 
 
 class DialectTest(fixtures.TestBase):
-    """python-side dialect tests.  """
+    """python-side dialect tests."""
 
     def test_version_parsing(self):
         def mock_conn(res):
index da550bcb9c308c47a47cb991c2e2ab2e2abea3cd..c83fe0f8a114b19ed18b92bc9eda4dc11fd6df96 100644 (file)
@@ -2443,7 +2443,7 @@ class SpecialTypesCompileTest(fixtures.TestBase, AssertsCompiledSQL):
 
 class SpecialTypesTest(fixtures.TablesTest, ComparesTables):
 
-    """test DDL and reflection of PG-specific types """
+    """test DDL and reflection of PG-specific types"""
 
     __only_on__ = ("postgresql >= 8.3.0",)
     __backend__ = True
index 20d509ca50a55e633ed81bf9a49e911f1a367a9e..a8292752ae8627f30b5337debc40d0d346ebce3e 100644 (file)
@@ -750,7 +750,7 @@ class ConcreteExtensionConfigTest(
         )
 
     def test_prop_on_base(self):
-        """test [ticket:2670] """
+        """test [ticket:2670]"""
 
         counter = mock.Mock()
 
index dd162731647379a2688ec69b4b7c58cbee7b85d5..061dbc6daf7ca4bf70d4d69cfcb3598864ae05f0 100644 (file)
@@ -4,9 +4,10 @@ from . import Base
 from .user import HasUser
 
 if TYPE_CHECKING:
-    from .user import User  # noqa
-    from sqlalchemy import Integer, Column  # noqa
+    from sqlalchemy import Column  # noqa
+    from sqlalchemy import Integer  # noqa
     from sqlalchemy.orm import RelationshipProperty  # noqa
+    from .user import User  # noqa
 
 
 class Address(Base, HasUser):
index 280fad6cf09446798188b9ef7aab2c7f687d1ed9..13ebda24e70a07670f76621fc88179dacbd7e5ce 100644 (file)
@@ -18,7 +18,7 @@ metadata = None
 
 
 def step_numbering(step):
-    """ order in whole steps """
+    """order in whole steps"""
 
     def f(index, collection):
         return step * index
index e09b1570e27743fcf3b7694fb85ad42694dc321b..a1e5c605bb4db43521a76e211172de2e50b3420a 100644 (file)
@@ -906,10 +906,10 @@ class DeclarativeInheritanceTest(DeclarativeTestBase):
             __tablename__ = "person"
 
         class Engineer(Person):
-            """ single table inheritance, no extra cols """
+            """single table inheritance, no extra cols"""
 
         class Manager(Person):
-            """ single table inheritance, no extra cols """
+            """single table inheritance, no extra cols"""
 
         is_(Engineer.id.property.columns[0], Person.__table__.c.id)
         is_(Manager.id.property.columns[0], Person.__table__.c.id)
index d983ddac94be98f5661e157f8f12ec9038633d60..b9f3ac01d1da8aa06ac54f575b63f616aa6a10b1 100644 (file)
@@ -1885,7 +1885,7 @@ class SubClassToSubClassMultiTest(AssertsCompiledSQL, fixtures.MappedTest):
 class JoinedloadWPolyOfTypeContinued(
     fixtures.DeclarativeMappedTest, testing.AssertsCompiledSQL
 ):
-    """test for #5082 """
+    """test for #5082"""
 
     @classmethod
     def setup_classes(cls):
@@ -2045,7 +2045,7 @@ class JoinedloadWPolyOfTypeContinued(
 class ContainsEagerMultipleOfType(
     fixtures.DeclarativeMappedTest, testing.AssertsCompiledSQL
 ):
-    """test for #5107 """
+    """test for #5107"""
 
     __dialect__ = "default"
 
index d6cd83d6a2a348bf7f118626992a39619609acd4..421e6320b2f19fd2339679ca5c23b6c14aacc5b5 100644 (file)
@@ -230,7 +230,7 @@ class TransScopingTest(_fixtures.FixtureTest):
     def test_autobegin_attr_change(
         self, case_, autocommit, begin, modify_unconditional, expire_on_commit
     ):
-        """test :ticket:`6360` """
+        """test :ticket:`6360`"""
 
         User, users = self.classes.User, self.tables.users
 
index f0df420fcfc13f985dff0c969b31925ef06e64c8..9c8c4a5fc85c34b2d12c7320b895e007d84047e5 100644 (file)
@@ -1046,7 +1046,7 @@ class UpdateDeleteTest(fixtures.MappedTest):
         not_in(jane, sess)
 
     def test_update_with_filter_statement(self):
-        """test for [ticket:4556] """
+        """test for [ticket:4556]"""
 
         User = self.classes.User
 
index 25d7e33ba03f365ceea21af5e6f140ec071ee836..59358aadf6ae6d8a6944dab0b60a45de9bb49d63 100644 (file)
@@ -265,8 +265,6 @@ class CTETest(fixtures.TestBase, AssertsCompiledSQL):
         )
 
     def test_recursive_union_alias_two(self):
-        """"""
-
         # I know, this is the PG VALUES keyword,
         # we're cheating here.  also yes we need the SELECT,
         # sorry PG.
index 8dba8cb83dde418043a353f167788668cdb403ab..7b2b6c57e7b5aa54252d99b0fe24b25914c1fcaf 100644 (file)
@@ -2618,7 +2618,7 @@ class LegacySequenceExecTest(fixtures.TestBase):
             self._assert_seq_result(testing.db.scalar(s.next_value()))
 
     def test_func_implicit_connectionless_scalar(self):
-        """test func.next_value().execute()/.scalar() works. """
+        """test func.next_value().execute()/.scalar() works."""
 
         with testing.expect_deprecated_20(
             r"The MetaData.bind argument is deprecated"
index 984379c6b72ee583b4110a3d7f63d4d409a44fa7..43d9133a79b95f4ff05b55eaaaab46604f9c8bea 100644 (file)
@@ -2107,7 +2107,7 @@ class InTest(fixtures.TestBase, testing.AssertsCompiledSQL):
         )
 
     def test_scalar_subquery_wo_type(self):
-        """ test for :ticket:`6181` """
+        """test for :ticket:`6181`"""
 
         m = MetaData()
         t = Table("t", m, Column("a", Integer))
index a22cf1098ccc8e391a112c68489dcda8209f5b70..14dc397f68bdc9e50630313bfbc68a242fb78065 100644 (file)
@@ -780,7 +780,7 @@ class QueryTest(fixtures.TablesTest):
         )
 
     def test_expanding_in_dont_alter_compiled(self, connection):
-        """test for issue #5048 """
+        """test for issue #5048"""
 
         class NameWithProcess(TypeDecorator):
             impl = String
index 37f75594b1fb284b14c660bd6136cc4c2e19831e..ff4f10f1ac837a0ba231214d099755ed1c0c526c 100644 (file)
@@ -147,7 +147,7 @@ class RoleTest(fixtures.TestBase):
         )
 
     def test_untyped_scalar_subquery(self):
-        """test for :ticket:`6181` """
+        """test for :ticket:`6181`"""
 
         c = column("q")
         subq = select(c).scalar_subquery()
index 26b0f6217ad9336471dc4e6c7bb80329be177976..8004e6a4cfe81f9832f672e01bb152af232c2777 100644 (file)
@@ -369,7 +369,7 @@ class UpdateTest(_UpdateFromTestBase, fixtures.TablesTest, AssertsCompiledSQL):
         )
 
     def test_labels_no_collision_index(self):
-        """test for [ticket:4911] """
+        """test for [ticket:4911]"""
 
         t = Table(
             "foo",
diff --git a/tox.ini b/tox.ini
index 6eea65c8f6942fab90212be1df5c112eec7bb6ea..81bd582d2d751af2f90f8c6c6f008f05dc241fc2 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -148,7 +148,7 @@ deps=
       # in case it requires a version pin
       pydocstyle
       pygments
-      black==20.8b1
+      black==21.5b1
 commands =
      flake8 ./lib/ ./test/ ./examples/ setup.py doc/build/conf.py {posargs}
      black --check .