From debeea97eeae4b4a39a2d50f2a2d96c366421a30 Mon Sep 17 00:00:00 2001 From: Federico Caselli Date: Wed, 12 May 2021 22:01:45 +0200 Subject: [PATCH] Update black flak8 and zimports Change-Id: I488c9557eda390e4a88319affd4c8813ee274f80 --- .pre-commit-config.yaml | 8 +++++--- examples/performance/single_inserts.py | 2 +- examples/space_invaders/space_invaders.py | 2 +- examples/versioned_rows/versioned_update_old_row.py | 2 +- lib/sqlalchemy/dialects/mssql/base.py | 2 +- lib/sqlalchemy/dialects/mysql/types.py | 2 +- lib/sqlalchemy/engine/interfaces.py | 6 ++++-- lib/sqlalchemy/ext/asyncio/result.py | 5 +++-- lib/sqlalchemy/orm/interfaces.py | 1 + lib/sqlalchemy/orm/relationships.py | 3 ++- lib/sqlalchemy/orm/strategy_options.py | 3 ++- lib/sqlalchemy/sql/elements.py | 5 +++-- lib/sqlalchemy/sql/roles.py | 2 +- lib/sqlalchemy/testing/suite/test_types.py | 2 +- test/dialect/oracle/test_reflection.py | 2 +- test/dialect/postgresql/test_dialect.py | 2 +- test/dialect/postgresql/test_types.py | 2 +- test/ext/declarative/test_inheritance.py | 2 +- test/ext/mypy/incremental/stubs_14/address.py | 5 +++-- test/ext/test_orderinglist.py | 2 +- test/orm/declarative/test_inheritance.py | 4 ++-- test/orm/inheritance/test_relationship.py | 4 ++-- test/orm/test_session.py | 2 +- test/orm/test_update_delete.py | 2 +- test/sql/test_cte.py | 2 -- test/sql/test_deprecations.py | 2 +- test/sql/test_operators.py | 2 +- test/sql/test_query.py | 2 +- test/sql/test_roles.py | 2 +- test/sql/test_update.py | 2 +- tox.ini | 2 +- 31 files changed, 47 insertions(+), 39 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c66c463ac6..ae35977b9d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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: diff --git a/examples/performance/single_inserts.py b/examples/performance/single_inserts.py index 2dd87d5b69..991d213a07 100644 --- a/examples/performance/single_inserts.py +++ b/examples/performance/single_inserts.py @@ -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) diff --git a/examples/space_invaders/space_invaders.py b/examples/space_invaders/space_invaders.py index ed6c47abc0..1690145db2 100644 --- a/examples/space_invaders/space_invaders.py +++ b/examples/space_invaders/space_invaders.py @@ -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"} diff --git a/examples/versioned_rows/versioned_update_old_row.py b/examples/versioned_rows/versioned_update_old_row.py index 5aa0f424af..0da28cf42d 100644 --- a/examples/versioned_rows/versioned_update_old_row.py +++ b/examples/versioned_rows/versioned_update_old_row.py @@ -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"] diff --git a/lib/sqlalchemy/dialects/mssql/base.py b/lib/sqlalchemy/dialects/mssql/base.py index e59221f834..750f3743bb 100644 --- a/lib/sqlalchemy/dialects/mssql/base.py +++ b/lib/sqlalchemy/dialects/mssql/base.py @@ -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) diff --git a/lib/sqlalchemy/dialects/mysql/types.py b/lib/sqlalchemy/dialects/mysql/types.py index 9a6b804b33..3318006e6c 100644 --- a/lib/sqlalchemy/dialects/mysql/types.py +++ b/lib/sqlalchemy/dialects/mysql/types.py @@ -395,7 +395,7 @@ class BIT(sqltypes.TypeEngine): class TIME(sqltypes.TIME): - """MySQL TIME type. """ + """MySQL TIME type.""" __visit_name__ = "TIME" diff --git a/lib/sqlalchemy/engine/interfaces.py b/lib/sqlalchemy/engine/interfaces.py index 47348ba767..0df7c954e0 100644 --- a/lib/sqlalchemy/engine/interfaces.py +++ b/lib/sqlalchemy/engine/interfaces.py @@ -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): diff --git a/lib/sqlalchemy/ext/asyncio/result.py b/lib/sqlalchemy/ext/asyncio/result.py index c299dafc99..6899fe0a61 100644 --- a/lib/sqlalchemy/ext/asyncio/result.py +++ b/lib/sqlalchemy/ext/asyncio/result.py @@ -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 diff --git a/lib/sqlalchemy/orm/interfaces.py b/lib/sqlalchemy/orm/interfaces.py index 6f77fd7065..68e1aa5cb0 100644 --- a/lib/sqlalchemy/orm/interfaces.py +++ b/lib/sqlalchemy/orm/interfaces.py @@ -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 diff --git a/lib/sqlalchemy/orm/relationships.py b/lib/sqlalchemy/orm/relationships.py index 2ed9d859ab..bf166e181e 100644 --- a/lib/sqlalchemy/orm/relationships.py +++ b/lib/sqlalchemy/orm/relationships.py @@ -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 diff --git a/lib/sqlalchemy/orm/strategy_options.py b/lib/sqlalchemy/orm/strategy_options.py index f61cf835d2..60ae69176c 100644 --- a/lib/sqlalchemy/orm/strategy_options.py +++ b/lib/sqlalchemy/orm/strategy_options.py @@ -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 diff --git a/lib/sqlalchemy/sql/elements.py b/lib/sqlalchemy/sql/elements.py index cdb1dbca8a..169a6d8461 100644 --- a/lib/sqlalchemy/sql/elements.py +++ b/lib/sqlalchemy/sql/elements.py @@ -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 diff --git a/lib/sqlalchemy/sql/roles.py b/lib/sqlalchemy/sql/roles.py index 7d64e83826..8982cb159b 100644 --- a/lib/sqlalchemy/sql/roles.py +++ b/lib/sqlalchemy/sql/roles.py @@ -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" diff --git a/lib/sqlalchemy/testing/suite/test_types.py b/lib/sqlalchemy/testing/suite/test_types.py index 3e54d87a44..468a1660e2 100644 --- a/lib/sqlalchemy/testing/suite/test_types.py +++ b/lib/sqlalchemy/testing/suite/test_types.py @@ -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 diff --git a/test/dialect/oracle/test_reflection.py b/test/dialect/oracle/test_reflection.py index f9ce1a30b1..acf7d75d54 100644 --- a/test/dialect/oracle/test_reflection.py +++ b/test/dialect/oracle/test_reflection.py @@ -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( diff --git a/test/dialect/postgresql/test_dialect.py b/test/dialect/postgresql/test_dialect.py index 1382788224..69bb41e2ce 100644 --- a/test/dialect/postgresql/test_dialect.py +++ b/test/dialect/postgresql/test_dialect.py @@ -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): diff --git a/test/dialect/postgresql/test_types.py b/test/dialect/postgresql/test_types.py index da550bcb9c..c83fe0f8a1 100644 --- a/test/dialect/postgresql/test_types.py +++ b/test/dialect/postgresql/test_types.py @@ -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 diff --git a/test/ext/declarative/test_inheritance.py b/test/ext/declarative/test_inheritance.py index 20d509ca50..a8292752ae 100644 --- a/test/ext/declarative/test_inheritance.py +++ b/test/ext/declarative/test_inheritance.py @@ -750,7 +750,7 @@ class ConcreteExtensionConfigTest( ) def test_prop_on_base(self): - """test [ticket:2670] """ + """test [ticket:2670]""" counter = mock.Mock() diff --git a/test/ext/mypy/incremental/stubs_14/address.py b/test/ext/mypy/incremental/stubs_14/address.py index dd16273164..061dbc6daf 100644 --- a/test/ext/mypy/incremental/stubs_14/address.py +++ b/test/ext/mypy/incremental/stubs_14/address.py @@ -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): diff --git a/test/ext/test_orderinglist.py b/test/ext/test_orderinglist.py index 280fad6cf0..13ebda24e7 100644 --- a/test/ext/test_orderinglist.py +++ b/test/ext/test_orderinglist.py @@ -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 diff --git a/test/orm/declarative/test_inheritance.py b/test/orm/declarative/test_inheritance.py index e09b1570e2..a1e5c605bb 100644 --- a/test/orm/declarative/test_inheritance.py +++ b/test/orm/declarative/test_inheritance.py @@ -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) diff --git a/test/orm/inheritance/test_relationship.py b/test/orm/inheritance/test_relationship.py index d983ddac94..b9f3ac01d1 100644 --- a/test/orm/inheritance/test_relationship.py +++ b/test/orm/inheritance/test_relationship.py @@ -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" diff --git a/test/orm/test_session.py b/test/orm/test_session.py index d6cd83d6a2..421e6320b2 100644 --- a/test/orm/test_session.py +++ b/test/orm/test_session.py @@ -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 diff --git a/test/orm/test_update_delete.py b/test/orm/test_update_delete.py index f0df420fcf..9c8c4a5fc8 100644 --- a/test/orm/test_update_delete.py +++ b/test/orm/test_update_delete.py @@ -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 diff --git a/test/sql/test_cte.py b/test/sql/test_cte.py index 25d7e33ba0..59358aadf6 100644 --- a/test/sql/test_cte.py +++ b/test/sql/test_cte.py @@ -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. diff --git a/test/sql/test_deprecations.py b/test/sql/test_deprecations.py index 8dba8cb83d..7b2b6c57e7 100644 --- a/test/sql/test_deprecations.py +++ b/test/sql/test_deprecations.py @@ -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" diff --git a/test/sql/test_operators.py b/test/sql/test_operators.py index 984379c6b7..43d9133a79 100644 --- a/test/sql/test_operators.py +++ b/test/sql/test_operators.py @@ -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)) diff --git a/test/sql/test_query.py b/test/sql/test_query.py index a22cf1098c..14dc397f68 100644 --- a/test/sql/test_query.py +++ b/test/sql/test_query.py @@ -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 diff --git a/test/sql/test_roles.py b/test/sql/test_roles.py index 37f75594b1..ff4f10f1ac 100644 --- a/test/sql/test_roles.py +++ b/test/sql/test_roles.py @@ -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() diff --git a/test/sql/test_update.py b/test/sql/test_update.py index 26b0f6217a..8004e6a4cf 100644 --- a/test/sql/test_update.py +++ b/test/sql/test_update.py @@ -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 6eea65c8f6..81bd582d2d 100644 --- 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 . -- 2.47.3