From: Mike Bayer Date: Mon, 28 Sep 2020 18:24:11 +0000 (-0400) Subject: upgrade to black 20.8b1 X-Git-Tag: rel_1_3_20~14 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=dc5d427a812c4303480ed63686be423f2299ff9a;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git upgrade to black 20.8b1 It's better, the majority of these changes look more readable to me. also found some docstrings that had formatting / quoting issues. Cross-implemented with master Change-Id: I582a45fde3a5648b2f36bab96bad56881321899b --- diff --git a/.github/workflows/scripts/can_install.py b/.github/workflows/scripts/can_install.py index 61685d9789..ecb24b5623 100644 --- a/.github/workflows/scripts/can_install.py +++ b/.github/workflows/scripts/can_install.py @@ -1,4 +1,5 @@ import sys + from packaging import tags to_check = "--" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index de29c68c6b..91111eb0ba 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,7 +2,7 @@ # See https://pre-commit.com/hooks.html for more hooks repos: - repo: https://github.com/python/black - rev: 19.10b0 + rev: 20.8b1 hooks: - id: black diff --git a/examples/dogpile_caching/caching_query.py b/examples/dogpile_caching/caching_query.py index 3d528b880d..20e04ebed3 100644 --- a/examples/dogpile_caching/caching_query.py +++ b/examples/dogpile_caching/caching_query.py @@ -47,15 +47,15 @@ class CachingQuery(Query): def __iter__(self): """override __iter__ to pull results from dogpile - if particular attributes have been configured. + if particular attributes have been configured. - Note that this approach does *not* detach the loaded objects from - the current session. If the cache backend is an in-process cache - (like "memory") and lives beyond the scope of the current session's - transaction, those objects may be expired. The method here can be - modified to first expunge() each loaded item from the current - session before returning the list of items, so that the items - in the cache are not the same ones in the current Session. + Note that this approach does *not* detach the loaded objects from + the current session. If the cache backend is an in-process cache + (like "memory") and lives beyond the scope of the current session's + transaction, those objects may be expired. The method here can be + modified to first expunge() each loaded item from the current + session before returning the list of items, so that the items + in the cache are not the same ones in the current Session. """ super_ = super(CachingQuery, self) @@ -67,15 +67,15 @@ class CachingQuery(Query): def _execute_and_instances(self, context): """override _execute_and_instances to pull results from dogpile - if the query is invoked directly from an external context. + if the query is invoked directly from an external context. - This method is necessary in order to maintain compatibility - with the "baked query" system now used by default in some - relationship loader scenarios. Note also the - RelationshipCache._generate_cache_key method which enables - the baked query to be used within lazy loads. + This method is necessary in order to maintain compatibility + with the "baked query" system now used by default in some + relationship loader scenarios. Note also the + RelationshipCache._generate_cache_key method which enables + the baked query to be used within lazy loads. - .. versionadded:: 1.2.7 + .. versionadded:: 1.2.7 """ super_ = super(CachingQuery, self) @@ -208,7 +208,7 @@ class FromCache(MapperOption): class RelationshipCache(MapperOption): """Specifies that a Query as called within a "lazy load" - should load results from a cache.""" + should load results from a cache.""" propagate_to_loaders = True diff --git a/examples/versioned_rows/versioned_rows_w_versionid.py b/examples/versioned_rows/versioned_rows_w_versionid.py index 4861fb3669..c1531dc06c 100644 --- a/examples/versioned_rows/versioned_rows_w_versionid.py +++ b/examples/versioned_rows/versioned_rows_w_versionid.py @@ -101,14 +101,17 @@ session.commit() e1.data = "e2" session.commit() -assert session.query( - Example.id, - Example.version_id, - Example.is_current_version, - Example.calc_is_current_version, - Example.data, -).order_by(Example.id, Example.version_id).all() == ( - [(1, 1, False, False, "e1"), (1, 2, True, True, "e2")] +assert ( + session.query( + Example.id, + Example.version_id, + Example.is_current_version, + Example.calc_is_current_version, + Example.data, + ) + .order_by(Example.id, Example.version_id) + .all() + == ([(1, 1, False, False, "e1"), (1, 2, True, True, "e2")]) ) # example 2, versioning with a parent @@ -159,12 +162,15 @@ session.commit() assert p1.child_id == 1 assert p1.child.version_id == 2 -assert session.query( - Child.id, - Child.version_id, - Child.is_current_version, - Child.calc_is_current_version, - Child.data, -).order_by(Child.id, Child.version_id).all() == ( - [(1, 1, False, False, "c1"), (1, 2, True, True, "c2")] +assert ( + session.query( + Child.id, + Child.version_id, + Child.is_current_version, + Child.calc_is_current_version, + Child.data, + ) + .order_by(Child.id, Child.version_id) + .all() + == ([(1, 1, False, False, "c1"), (1, 2, True, True, "c2")]) ) diff --git a/examples/vertical/dictlike-polymorphic.py b/examples/vertical/dictlike-polymorphic.py index 73d12ee4f2..3a79fade87 100644 --- a/examples/vertical/dictlike-polymorphic.py +++ b/examples/vertical/dictlike-polymorphic.py @@ -67,9 +67,8 @@ class PolymorphicVerticalProperty(object): @value.comparator class value(PropComparator): - """A comparator for .value, builds a polymorphic comparison via CASE. - - """ + """A comparator for .value, builds a polymorphic comparison via + CASE.""" def __init__(self, cls): self.cls = cls diff --git a/lib/sqlalchemy/__init__.py b/lib/sqlalchemy/__init__.py index ca351aee42..406911a3b1 100644 --- a/lib/sqlalchemy/__init__.py +++ b/lib/sqlalchemy/__init__.py @@ -124,7 +124,7 @@ from .engine import create_engine # noqa nosort from .engine import engine_from_config # noqa nosort -__version__ = '1.3.20' +__version__ = "1.3.20" def __go(lcls): diff --git a/lib/sqlalchemy/connectors/mxodbc.py b/lib/sqlalchemy/connectors/mxodbc.py index 0a34cfe003..57c7e0b2a6 100644 --- a/lib/sqlalchemy/connectors/mxodbc.py +++ b/lib/sqlalchemy/connectors/mxodbc.py @@ -54,7 +54,7 @@ class MxODBCConnector(Connector): @classmethod def _load_mx_exceptions(cls): - """ Import mxODBC exception classes into the module namespace, + """Import mxODBC exception classes into the module namespace, as if they had been imported normally. This is done here to avoid requiring all SQLAlchemy users to install mxODBC. """ @@ -72,7 +72,7 @@ class MxODBCConnector(Connector): return connect def _error_handler(self): - """ Return a handler that adjusts mxODBC's raised Warnings to + """Return a handler that adjusts mxODBC's raised Warnings to emit Python standard warnings. """ from mx.ODBC.Error import Warning as MxOdbcWarning diff --git a/lib/sqlalchemy/dialects/mssql/base.py b/lib/sqlalchemy/dialects/mssql/base.py index 53a8fc8b5e..7fccea35b3 100644 --- a/lib/sqlalchemy/dialects/mssql/base.py +++ b/lib/sqlalchemy/dialects/mssql/base.py @@ -968,7 +968,7 @@ class TIME(sqltypes.TIME): self.__zero_date, value.time() ) elif isinstance(value, datetime.time): - """ issue #5339 + """issue #5339 per: https://github.com/mkleehammer/pyodbc/wiki/Tips-and-Tricks-by-Database-Platform#time-columns pass TIME value as string """ # noqa @@ -1195,9 +1195,7 @@ class SQL_VARIANT(sqltypes.TypeEngine): class TryCast(sql.elements.Cast): - """Represent a SQL Server TRY_CAST expression. - - """ + """Represent a SQL Server TRY_CAST expression.""" __visit_name__ = "try_cast" diff --git a/lib/sqlalchemy/dialects/mssql/mxodbc.py b/lib/sqlalchemy/dialects/mssql/mxodbc.py index 5df1351d2b..011086db15 100644 --- a/lib/sqlalchemy/dialects/mssql/mxodbc.py +++ b/lib/sqlalchemy/dialects/mssql/mxodbc.py @@ -55,8 +55,7 @@ from ...connectors.mxodbc import MxODBCConnector class _MSNumeric_mxodbc(_MSNumeric_pyodbc): - """Include pyodbc's numeric processor. - """ + """Include pyodbc's numeric processor.""" class _MSDate_mxodbc(_MSDate): diff --git a/lib/sqlalchemy/dialects/mysql/cymysql.py b/lib/sqlalchemy/dialects/mysql/cymysql.py index 2b45f5ddba..d51c03a052 100644 --- a/lib/sqlalchemy/dialects/mysql/cymysql.py +++ b/lib/sqlalchemy/dialects/mysql/cymysql.py @@ -28,8 +28,8 @@ from ... import util class _cymysqlBIT(BIT): def result_processor(self, dialect, coltype): - """Convert a MySQL's 64 bit, variable length binary string to a long. - """ + """Convert a MySQL's 64 bit, variable length binary string to a + long.""" def process(value): if value is not None: diff --git a/lib/sqlalchemy/dialects/mysql/types.py b/lib/sqlalchemy/dialects/mysql/types.py index 3b455cfb1f..5949750001 100644 --- a/lib/sqlalchemy/dialects/mysql/types.py +++ b/lib/sqlalchemy/dialects/mysql/types.py @@ -440,9 +440,7 @@ class TIME(sqltypes.TIME): class TIMESTAMP(sqltypes.TIMESTAMP): - """MySQL TIMESTAMP type. - - """ + """MySQL TIMESTAMP type.""" __visit_name__ = "TIMESTAMP" @@ -467,9 +465,7 @@ class TIMESTAMP(sqltypes.TIMESTAMP): class DATETIME(sqltypes.DATETIME): - """MySQL DATETIME type. - - """ + """MySQL DATETIME type.""" __visit_name__ = "DATETIME" diff --git a/lib/sqlalchemy/dialects/oracle/cx_oracle.py b/lib/sqlalchemy/dialects/oracle/cx_oracle.py index ece6401f32..18150bd334 100644 --- a/lib/sqlalchemy/dialects/oracle/cx_oracle.py +++ b/lib/sqlalchemy/dialects/oracle/cx_oracle.py @@ -1001,7 +1001,11 @@ class OracleDialect_cx_oracle(OracleDialect): # allow all strings to come back natively as Unicode elif ( dialect.coerce_to_unicode - and default_type in (cx_Oracle.STRING, cx_Oracle.FIXED_CHAR,) + and default_type + in ( + cx_Oracle.STRING, + cx_Oracle.FIXED_CHAR, + ) and default_type is not cx_Oracle.CLOB and default_type is not cx_Oracle.NCLOB ): @@ -1049,7 +1053,9 @@ class OracleDialect_cx_oracle(OracleDialect): cx_Oracle.BLOB, ): return cursor.var( - cx_Oracle.LONG_BINARY, size, cursor.arraysize, + cx_Oracle.LONG_BINARY, + size, + cursor.arraysize, ) return output_type_handler diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py index 2c68a5969b..1295f76597 100644 --- a/lib/sqlalchemy/dialects/postgresql/base.py +++ b/lib/sqlalchemy/dialects/postgresql/base.py @@ -1311,7 +1311,7 @@ class UUID(sqltypes.TypeEngine): as Python uuid objects, converting to/from string via the DBAPI. - """ + """ if as_uuid and _python_UUID is None: raise NotImplementedError( "This version of Python does not support " @@ -2609,10 +2609,14 @@ class PGDialect(default.DefaultDialect): def initialize(self, connection): super(PGDialect, self).initialize(connection) - self.implicit_returning = self.server_version_info > ( - 8, - 2, - ) and self.__dict__.get("implicit_returning", True) + self.implicit_returning = ( + self.server_version_info + > ( + 8, + 2, + ) + and self.__dict__.get("implicit_returning", True) + ) self.supports_native_enum = self.server_version_info >= (8, 3) if not self.supports_native_enum: self.colspecs = self.colspecs.copy() diff --git a/lib/sqlalchemy/dialects/postgresql/hstore.py b/lib/sqlalchemy/dialects/postgresql/hstore.py index 4e048feb05..2ef700771c 100644 --- a/lib/sqlalchemy/dialects/postgresql/hstore.py +++ b/lib/sqlalchemy/dialects/postgresql/hstore.py @@ -160,13 +160,11 @@ class HSTORE(sqltypes.Indexable, sqltypes.Concatenable, sqltypes.TypeEngine): return self.operate(HAS_KEY, other, result_type=sqltypes.Boolean) def has_all(self, other): - """Boolean expression. Test for presence of all keys in jsonb - """ + """Boolean expression. Test for presence of all keys in jsonb""" return self.operate(HAS_ALL, other, result_type=sqltypes.Boolean) def has_any(self, other): - """Boolean expression. Test for presence of any key in jsonb - """ + """Boolean expression. Test for presence of any key in jsonb""" return self.operate(HAS_ANY, other, result_type=sqltypes.Boolean) def contains(self, other, **kwargs): diff --git a/lib/sqlalchemy/dialects/postgresql/json.py b/lib/sqlalchemy/dialects/postgresql/json.py index 255f1af21d..47e924eb97 100644 --- a/lib/sqlalchemy/dialects/postgresql/json.py +++ b/lib/sqlalchemy/dialects/postgresql/json.py @@ -195,7 +195,7 @@ class JSON(sqltypes.JSON): .. versionadded:: 1.1 - """ + """ super(JSON, self).__init__(none_as_null=none_as_null) if astext_type is not None: self.astext_type = astext_type @@ -291,13 +291,11 @@ class JSONB(JSON): return self.operate(HAS_KEY, other, result_type=sqltypes.Boolean) def has_all(self, other): - """Boolean expression. Test for presence of all keys in jsonb - """ + """Boolean expression. Test for presence of all keys in jsonb""" return self.operate(HAS_ALL, other, result_type=sqltypes.Boolean) def has_any(self, other): - """Boolean expression. Test for presence of any key in jsonb - """ + """Boolean expression. Test for presence of any key in jsonb""" return self.operate(HAS_ANY, other, result_type=sqltypes.Boolean) def contains(self, other, **kwargs): diff --git a/lib/sqlalchemy/dialects/postgresql/ranges.py b/lib/sqlalchemy/dialects/postgresql/ranges.py index a31d958ed9..ddc12c096d 100644 --- a/lib/sqlalchemy/dialects/postgresql/ranges.py +++ b/lib/sqlalchemy/dialects/postgresql/ranges.py @@ -100,48 +100,36 @@ class RangeOperators(object): class INT4RANGE(RangeOperators, sqltypes.TypeEngine): - """Represent the PostgreSQL INT4RANGE type. - - """ + """Represent the PostgreSQL INT4RANGE type.""" __visit_name__ = "INT4RANGE" class INT8RANGE(RangeOperators, sqltypes.TypeEngine): - """Represent the PostgreSQL INT8RANGE type. - - """ + """Represent the PostgreSQL INT8RANGE type.""" __visit_name__ = "INT8RANGE" class NUMRANGE(RangeOperators, sqltypes.TypeEngine): - """Represent the PostgreSQL NUMRANGE type. - - """ + """Represent the PostgreSQL NUMRANGE type.""" __visit_name__ = "NUMRANGE" class DATERANGE(RangeOperators, sqltypes.TypeEngine): - """Represent the PostgreSQL DATERANGE type. - - """ + """Represent the PostgreSQL DATERANGE type.""" __visit_name__ = "DATERANGE" class TSRANGE(RangeOperators, sqltypes.TypeEngine): - """Represent the PostgreSQL TSRANGE type. - - """ + """Represent the PostgreSQL TSRANGE type.""" __visit_name__ = "TSRANGE" class TSTZRANGE(RangeOperators, sqltypes.TypeEngine): - """Represent the PostgreSQL TSTZRANGE type. - - """ + """Represent the PostgreSQL TSTZRANGE type.""" __visit_name__ = "TSTZRANGE" diff --git a/lib/sqlalchemy/engine/base.py b/lib/sqlalchemy/engine/base.py index 6c9eb41ccd..5f46021984 100644 --- a/lib/sqlalchemy/engine/base.py +++ b/lib/sqlalchemy/engine/base.py @@ -344,7 +344,7 @@ class Connection(Connectable): return c def get_execution_options(self): - """ Get the non-SQL options which will take effect during execution. + """Get the non-SQL options which will take effect during execution. .. versionadded:: 1.3 @@ -1746,9 +1746,7 @@ class Transaction(object): self.connection._discard_transaction(self) def rollback(self): - """Roll back this :class:`.Transaction`. - - """ + """Roll back this :class:`.Transaction`.""" if self._parent.is_active: self._do_rollback() self.is_active = False @@ -2020,7 +2018,7 @@ class Engine(Connectable, log.Identified): return OptionEngine(self, opt) def get_execution_options(self): - """ Get the non-SQL options which will take effect during execution. + """Get the non-SQL options which will take effect during execution. .. versionadded: 1.3 diff --git a/lib/sqlalchemy/engine/interfaces.py b/lib/sqlalchemy/engine/interfaces.py index b424ce90df..e57ec68471 100644 --- a/lib/sqlalchemy/engine/interfaces.py +++ b/lib/sqlalchemy/engine/interfaces.py @@ -532,7 +532,7 @@ class Dialect(object): :param dbapi_connection: a DBAPI connection, typically proxied within a :class:`.ConnectionFairy`. - """ + """ raise NotImplementedError() @@ -543,7 +543,7 @@ class Dialect(object): :param dbapi_connection: a DBAPI connection, typically proxied within a :class:`.ConnectionFairy`. - """ + """ raise NotImplementedError() @@ -1294,8 +1294,7 @@ class Connectable(object): ":meth:`_schema.MetaData.create_all`.", ) def create(self, entity, **kwargs): - """Emit CREATE statements for the given schema entity. - """ + """Emit CREATE statements for the given schema entity.""" raise NotImplementedError() @@ -1308,8 +1307,7 @@ class Connectable(object): ":meth:`_schema.MetaData.drop_all`.", ) def drop(self, entity, **kwargs): - """Emit DROP statements for the given schema entity. - """ + """Emit DROP statements for the given schema entity.""" raise NotImplementedError() diff --git a/lib/sqlalchemy/engine/reflection.py b/lib/sqlalchemy/engine/reflection.py index 93d5827d7c..283c6f3197 100644 --- a/lib/sqlalchemy/engine/reflection.py +++ b/lib/sqlalchemy/engine/reflection.py @@ -150,8 +150,7 @@ class Inspector(object): return self.dialect.default_schema_name def get_schema_names(self): - """Return all schema names. - """ + """Return all schema names.""" if hasattr(self.dialect, "get_schema_names"): return self.dialect.get_schema_names( diff --git a/lib/sqlalchemy/event/attr.py b/lib/sqlalchemy/event/attr.py index cefb640a18..d9f31a8006 100644 --- a/lib/sqlalchemy/event/attr.py +++ b/lib/sqlalchemy/event/attr.py @@ -373,7 +373,7 @@ class _ListenerCollection(_CompoundListener): def _update(self, other, only_propagate=True): """Populate from the listeners in another :class:`_Dispatch` - object.""" + object.""" existing_listeners = self.listeners existing_listener_set = set(existing_listeners) diff --git a/lib/sqlalchemy/event/base.py b/lib/sqlalchemy/event/base.py index a87c1fe448..560717cd27 100644 --- a/lib/sqlalchemy/event/base.py +++ b/lib/sqlalchemy/event/base.py @@ -142,7 +142,7 @@ class _Dispatch(object): def _update(self, other, only_propagate=True): """Populate from the listeners in another :class:`_Dispatch` - object.""" + object.""" for ls in other._event_descriptors: if isinstance(ls, _EmptyListener): continue diff --git a/lib/sqlalchemy/event/registry.py b/lib/sqlalchemy/event/registry.py index 19b9174b71..56b310276d 100644 --- a/lib/sqlalchemy/event/registry.py +++ b/lib/sqlalchemy/event/registry.py @@ -139,8 +139,7 @@ def _clear(owner, elements): class _EventKey(object): - """Represent :func:`.listen` arguments. - """ + """Represent :func:`.listen` arguments.""" __slots__ = ( "target", @@ -239,8 +238,7 @@ class _EventKey(object): collection.remove(self.with_wrapper(listener_fn)) def contains(self): - """Return True if this event key is registered to listen. - """ + """Return True if this event key is registered to listen.""" return self._key in _key_to_collection def base_listen( diff --git a/lib/sqlalchemy/exc.py b/lib/sqlalchemy/exc.py index b86803097d..a03fd8bb52 100644 --- a/lib/sqlalchemy/exc.py +++ b/lib/sqlalchemy/exc.py @@ -35,7 +35,11 @@ class SQLAlchemyError(Exception): else: return ( "(Background on this error at: " - "http://sqlalche.me/e/%s/%s)" % (_version_token, self.code,) + "http://sqlalche.me/e/%s/%s)" + % ( + _version_token, + self.code, + ) ) def _message(self, as_unicode=compat.py3k): diff --git a/lib/sqlalchemy/ext/associationproxy.py b/lib/sqlalchemy/ext/associationproxy.py index 5151ddb2a3..2f8d8627c3 100644 --- a/lib/sqlalchemy/ext/associationproxy.py +++ b/lib/sqlalchemy/ext/associationproxy.py @@ -840,8 +840,7 @@ class AmbiguousAssociationProxyInstance(AssociationProxyInstance): class ObjectAssociationProxyInstance(AssociationProxyInstance): - """an :class:`.AssociationProxyInstance` that has an object as a target. - """ + """an :class:`.AssociationProxyInstance` that has an object as a target.""" _target_is_object = True _is_canonical = True diff --git a/lib/sqlalchemy/ext/baked.py b/lib/sqlalchemy/ext/baked.py index 229ad1506f..d510f6451e 100644 --- a/lib/sqlalchemy/ext/baked.py +++ b/lib/sqlalchemy/ext/baked.py @@ -171,8 +171,7 @@ class BakedQuery(object): return self._cache_key + (session._query_cls,) def _with_lazyload_options(self, options, effective_path, cache_path=None): - """Cloning version of _add_lazyload_options. - """ + """Cloning version of _add_lazyload_options.""" q = self._clone() q._add_lazyload_options(options, effective_path, cache_path=cache_path) return q diff --git a/lib/sqlalchemy/ext/hybrid.py b/lib/sqlalchemy/ext/hybrid.py index 3361c95efe..c654313cf1 100644 --- a/lib/sqlalchemy/ext/hybrid.py +++ b/lib/sqlalchemy/ext/hybrid.py @@ -950,7 +950,7 @@ class hybrid_property(interfaces.InspectionAttrInfo): :ref:`hybrid_reuse_subclass` - """ + """ return self def getter(self, fget): diff --git a/lib/sqlalchemy/ext/orderinglist.py b/lib/sqlalchemy/ext/orderinglist.py index 1f0e9d7e13..6882d64714 100644 --- a/lib/sqlalchemy/ext/orderinglist.py +++ b/lib/sqlalchemy/ext/orderinglist.py @@ -377,7 +377,7 @@ class OrderingList(list): def _reconstitute(cls, dict_, items): - """ Reconstitute an :class:`.OrderingList`. + """Reconstitute an :class:`.OrderingList`. This is the adjoint to :meth:`.OrderingList.__reduce__`. It is used for unpickling :class:`.OrderingList` objects. diff --git a/lib/sqlalchemy/inspection.py b/lib/sqlalchemy/inspection.py index 270f189bef..4d9ee30c44 100644 --- a/lib/sqlalchemy/inspection.py +++ b/lib/sqlalchemy/inspection.py @@ -54,7 +54,7 @@ def inspect(subject, raiseerr=True): :class:`sqlalchemy.exc.NoInspectionAvailable` is raised. If ``False``, ``None`` is returned. - """ + """ type_ = type(subject) for cls in type_.__mro__: if cls in _registrars: diff --git a/lib/sqlalchemy/orm/attributes.py b/lib/sqlalchemy/orm/attributes.py index 32be3b5aa3..15476a2c46 100644 --- a/lib/sqlalchemy/orm/attributes.py +++ b/lib/sqlalchemy/orm/attributes.py @@ -886,9 +886,9 @@ class ScalarAttributeImpl(AttributeImpl): class ScalarObjectAttributeImpl(ScalarAttributeImpl): """represents a scalar-holding InstrumentedAttribute, - where the target object is also instrumented. + where the target object is also instrumented. - Adds events to delete/set operations. + Adds events to delete/set operations. """ @@ -983,9 +983,7 @@ class ScalarObjectAttributeImpl(ScalarAttributeImpl): check_old=None, pop=False, ): - """Set a value on the given InstanceState. - - """ + """Set a value on the given InstanceState.""" if self.dispatch._active_history: old = self.get( state, diff --git a/lib/sqlalchemy/orm/deprecated_interfaces.py b/lib/sqlalchemy/orm/deprecated_interfaces.py index ad407f5e6a..fcc41bb67d 100644 --- a/lib/sqlalchemy/orm/deprecated_interfaces.py +++ b/lib/sqlalchemy/orm/deprecated_interfaces.py @@ -398,7 +398,7 @@ class SessionExtension(object): """Execute before flush process has started. `instances` is an optional list of objects which were passed to - the ``flush()`` method. """ + the ``flush()`` method.""" def after_flush(self, session, flush_context): """Execute after flush has completed, but before commit has been @@ -415,18 +415,18 @@ class SessionExtension(object): This will be when the 'new', 'dirty', and 'deleted' lists are in their final state. An actual commit() may or may not have occurred, depending on whether or not the flush started its own - transaction or participated in a larger transaction. """ + transaction or participated in a larger transaction.""" def after_begin(self, session, transaction, connection): """Execute after a transaction is begun on a connection `transaction` is the SessionTransaction. This method is called - after an engine level transaction is begun on a connection. """ + after an engine level transaction is begun on a connection.""" def after_attach(self, session, instance): """Execute after an instance is attached to a session. - This is called after an add, delete or merge. """ + This is called after an add, delete or merge.""" def after_bulk_update(self, session, query, query_context, result): """Execute after a bulk update operation to the session. diff --git a/lib/sqlalchemy/orm/descriptor_props.py b/lib/sqlalchemy/orm/descriptor_props.py index c23197adad..ca84a30988 100644 --- a/lib/sqlalchemy/orm/descriptor_props.py +++ b/lib/sqlalchemy/orm/descriptor_props.py @@ -27,7 +27,7 @@ from ..sql import expression class DescriptorProperty(MapperProperty): """:class:`.MapperProperty` which proxies access to a - user-defined descriptor.""" + user-defined descriptor.""" doc = None diff --git a/lib/sqlalchemy/orm/loading.py b/lib/sqlalchemy/orm/loading.py index a255cccc7b..9b4119ef8b 100644 --- a/lib/sqlalchemy/orm/loading.py +++ b/lib/sqlalchemy/orm/loading.py @@ -362,7 +362,7 @@ def _instance_processor( _polymorphic_from=None, ): """Produce a mapper level row processor callable - which processes rows into mapped instances.""" + which processes rows into mapped instances.""" # note that this method, most of which exists in a closure # called _instance(), resists being broken out, as @@ -878,9 +878,7 @@ def _decorate_polymorphic_switch( class PostLoad(object): - """Track loaders and states for "post load" operations. - - """ + """Track loaders and states for "post load" operations.""" __slots__ = "loaders", "states", "load_keys" diff --git a/lib/sqlalchemy/orm/mapper.py b/lib/sqlalchemy/orm/mapper.py index 0169532557..6f3170a9ed 100644 --- a/lib/sqlalchemy/orm/mapper.py +++ b/lib/sqlalchemy/orm/mapper.py @@ -1348,8 +1348,7 @@ class Mapper(InspectionAttr): @classmethod def _configure_all(cls): - """Class-level path to the :func:`.configure_mappers` call. - """ + """Class-level path to the :func:`.configure_mappers` call.""" configure_mappers() def dispose(self): @@ -1864,7 +1863,7 @@ class Mapper(InspectionAttr): def _property_from_column(self, key, prop): """generate/update a :class:`.ColumnProprerty` given a - :class:`_schema.Column` object. """ + :class:`_schema.Column` object.""" # we were passed a Column or a list of Columns; # generate a properties.ColumnProperty @@ -2052,8 +2051,7 @@ class Mapper(InspectionAttr): return key in self._props def get_property(self, key, _configure_mappers=True): - """return a MapperProperty associated with the given key. - """ + """return a MapperProperty associated with the given key.""" if _configure_mappers and Mapper._new_mappers: configure_mappers() diff --git a/lib/sqlalchemy/orm/query.py b/lib/sqlalchemy/orm/query.py index 7de2d939c8..e7115dd317 100644 --- a/lib/sqlalchemy/orm/query.py +++ b/lib/sqlalchemy/orm/query.py @@ -1705,7 +1705,7 @@ class Query(object): return self.with_hint(None, text, dialect_name) def get_execution_options(self): - """ Get the non-SQL options which will take effect during execution. + """Get the non-SQL options which will take effect during execution. .. versionadded:: 1.3 @@ -1717,7 +1717,7 @@ class Query(object): @_generative() def execution_options(self, **kwargs): - """ Set non-SQL options which take effect during execution. + """Set non-SQL options which take effect during execution. The options are the same as those accepted by :meth:`_engine.Connection.execution_options`. diff --git a/lib/sqlalchemy/orm/relationships.py b/lib/sqlalchemy/orm/relationships.py index 8e4bcd63ca..59044d35b7 100644 --- a/lib/sqlalchemy/orm/relationships.py +++ b/lib/sqlalchemy/orm/relationships.py @@ -3525,7 +3525,7 @@ class JoinCondition(object): class _ColInAnnotations(object): """Seralizable equivalent to: - lambda c: "name" in c._annotations + lambda c: "name" in c._annotations """ def __init__(self, name): diff --git a/lib/sqlalchemy/orm/session.py b/lib/sqlalchemy/orm/session.py index b3cc1334db..5ed79ea503 100644 --- a/lib/sqlalchemy/orm/session.py +++ b/lib/sqlalchemy/orm/session.py @@ -1539,7 +1539,8 @@ class Session(_SessionClassMethods): except sa_exc.NoInspectionAvailable as err: if isinstance(mapper, type): util.raise_( - exc.UnmappedClassError(mapper), replace_context=err, + exc.UnmappedClassError(mapper), + replace_context=err, ) else: raise @@ -1685,7 +1686,8 @@ class Session(_SessionClassMethods): state = attributes.instance_state(instance) except exc.NO_STATE as err: util.raise_( - exc.UnmappedInstanceError(instance), replace_context=err, + exc.UnmappedInstanceError(instance), + replace_context=err, ) self._expire_state(state, attribute_names) @@ -1797,7 +1799,8 @@ class Session(_SessionClassMethods): state = attributes.instance_state(instance) except exc.NO_STATE as err: util.raise_( - exc.UnmappedInstanceError(instance), replace_context=err, + exc.UnmappedInstanceError(instance), + replace_context=err, ) self._expire_state(state, attribute_names) @@ -1854,7 +1857,8 @@ class Session(_SessionClassMethods): state = attributes.instance_state(instance) except exc.NO_STATE as err: util.raise_( - exc.UnmappedInstanceError(instance), replace_context=err, + exc.UnmappedInstanceError(instance), + replace_context=err, ) if state.session_id is not self.hash_key: raise sa_exc.InvalidRequestError( @@ -2008,7 +2012,8 @@ class Session(_SessionClassMethods): state = attributes.instance_state(instance) except exc.NO_STATE as err: util.raise_( - exc.UnmappedInstanceError(instance), replace_context=err, + exc.UnmappedInstanceError(instance), + replace_context=err, ) self._save_or_update_state(state) @@ -2045,7 +2050,8 @@ class Session(_SessionClassMethods): state = attributes.instance_state(instance) except exc.NO_STATE as err: util.raise_( - exc.UnmappedInstanceError(instance), replace_context=err, + exc.UnmappedInstanceError(instance), + replace_context=err, ) self._delete_impl(state, instance, head=True) @@ -2476,7 +2482,8 @@ class Session(_SessionClassMethods): state = attributes.instance_state(instance) except exc.NO_STATE as err: util.raise_( - exc.UnmappedInstanceError(instance), replace_context=err, + exc.UnmappedInstanceError(instance), + replace_context=err, ) return self._contains_state(state) @@ -2575,7 +2582,8 @@ class Session(_SessionClassMethods): except exc.NO_STATE as err: util.raise_( - exc.UnmappedInstanceError(o), replace_context=err, + exc.UnmappedInstanceError(o), + replace_context=err, ) objset.add(state) else: @@ -3445,7 +3453,8 @@ def object_session(instance): state = attributes.instance_state(instance) except exc.NO_STATE as err: util.raise_( - exc.UnmappedInstanceError(instance), replace_context=err, + exc.UnmappedInstanceError(instance), + replace_context=err, ) else: return _state_session(state) diff --git a/lib/sqlalchemy/orm/state.py b/lib/sqlalchemy/orm/state.py index e1aa4ddc29..70ff8d80d0 100644 --- a/lib/sqlalchemy/orm/state.py +++ b/lib/sqlalchemy/orm/state.py @@ -212,7 +212,7 @@ class InstanceState(interfaces.InspectionAttrInfo): :ref:`session_object_states` - """ + """ return self.key is not None and self._attached and not self._deleted @property @@ -529,7 +529,7 @@ class InstanceState(interfaces.InspectionAttrInfo): def _reset(self, dict_, key): """Remove the given attribute and any - callables associated with it.""" + callables associated with it.""" old = dict_.pop(key, None) if old is not None and self.manager[key].impl.collection: diff --git a/lib/sqlalchemy/schema.py b/lib/sqlalchemy/schema.py index cbc3716a93..1bf849a92a 100644 --- a/lib/sqlalchemy/schema.py +++ b/lib/sqlalchemy/schema.py @@ -48,8 +48,8 @@ from .sql.schema import DefaultGenerator # noqa from .sql.schema import FetchedValue # noqa from .sql.schema import ForeignKey # noqa from .sql.schema import ForeignKeyConstraint # noqa -from .sql.schema import Index # noqa from .sql.schema import IdentityOptions # noqa +from .sql.schema import Index # noqa from .sql.schema import MetaData # noqa from .sql.schema import PassiveDefault # noqa from .sql.schema import PrimaryKeyConstraint # noqa diff --git a/lib/sqlalchemy/sql/base.py b/lib/sqlalchemy/sql/base.py index 0c350d3f48..ed85cd4d5e 100644 --- a/lib/sqlalchemy/sql/base.py +++ b/lib/sqlalchemy/sql/base.py @@ -403,9 +403,7 @@ class Executable(Generative): return self._execution_options def execute(self, *multiparams, **params): - """Compile and execute this :class:`.Executable`. - - """ + """Compile and execute this :class:`.Executable`.""" e = self.bind if e is None: label = getattr(self, "description", self.__class__.__name__) @@ -492,18 +490,18 @@ class ColumnCollection(util.OrderedProperties): def replace(self, column): """Add the given column to this collection, removing unaliased - versions of this column as well as existing columns with the - same key. + versions of this column as well as existing columns with the + same key. - E.g.:: + E.g.:: - t = Table('sometable', metadata, Column('col1', Integer)) - t.columns.replace(Column('col1', Integer, key='columnone')) + t = Table('sometable', metadata, Column('col1', Integer)) + t.columns.replace(Column('col1', Integer, key='columnone')) - will remove the original 'col1' from the collection, and add - the new column under the name 'columnname'. + will remove the original 'col1' from the collection, and add + the new column under the name 'columnname'. - Used by schema.Column to override columns during table reflection. + Used by schema.Column to override columns during table reflection. """ remove_col = None diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index f06429bb94..3864af45b3 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -329,8 +329,7 @@ class Compiled(object): "does nothing.", ) def compile(self): - """Produce the internal string representation of this element. - """ + """Produce the internal string representation of this element.""" pass def _execute_on_connection(self, connection, multiparams, params): diff --git a/lib/sqlalchemy/sql/ddl.py b/lib/sqlalchemy/sql/ddl.py index 3b16394dfd..1e3d110b69 100644 --- a/lib/sqlalchemy/sql/ddl.py +++ b/lib/sqlalchemy/sql/ddl.py @@ -1038,7 +1038,9 @@ class SchemaDropper(DDLBase): def sort_tables( - tables, skip_fn=None, extra_dependencies=None, + tables, + skip_fn=None, + extra_dependencies=None, ): """Sort a collection of :class:`_schema.Table` objects based on dependency. diff --git a/lib/sqlalchemy/sql/dml.py b/lib/sqlalchemy/sql/dml.py index c653dcef3c..0362435d2f 100644 --- a/lib/sqlalchemy/sql/dml.py +++ b/lib/sqlalchemy/sql/dml.py @@ -31,9 +31,7 @@ from .. import util class UpdateBase( HasCTE, DialectKWArgs, HasPrefixes, Executable, ClauseElement ): - """Form the base for ``INSERT``, ``UPDATE``, and ``DELETE`` statements. - - """ + """Form the base for ``INSERT``, ``UPDATE``, and ``DELETE`` statements.""" __visit_name__ = "update_base" diff --git a/lib/sqlalchemy/sql/elements.py b/lib/sqlalchemy/sql/elements.py index 64824df42d..86cf950000 100644 --- a/lib/sqlalchemy/sql/elements.py +++ b/lib/sqlalchemy/sql/elements.py @@ -3351,8 +3351,8 @@ class Slice(ColumnElement): class IndexExpression(BinaryExpression): - """Represent the class of expressions that are like an "index" operation. - """ + """Represent the class of expressions that are like an "index" + operation.""" pass diff --git a/lib/sqlalchemy/sql/schema.py b/lib/sqlalchemy/sql/schema.py index 2d8097114a..469a3af72b 100644 --- a/lib/sqlalchemy/sql/schema.py +++ b/lib/sqlalchemy/sql/schema.py @@ -875,9 +875,7 @@ class Table(DialectKWArgs, SchemaItem, TableClause): ":class:`.DDLEvents`.", ) def append_ddl_listener(self, event_name, listener): - """Append a DDL event listener to this ``Table``. - - """ + """Append a DDL event listener to this ``Table``.""" def adapt_listener(target, connection, **kw): listener(event_name, target, connection) @@ -2815,8 +2813,7 @@ class DefaultClause(FetchedValue): "future release. Please refer to :class:`.DefaultClause`.", ) class PassiveDefault(DefaultClause): - """A DDL-specified DEFAULT column value. - """ + """A DDL-specified DEFAULT column value.""" def __init__(self, *arg, **kw): DefaultClause.__init__(self, *arg, **kw) @@ -3698,10 +3695,14 @@ class PrimaryKeyConstraint(ColumnCollectionConstraint): if col.autoincrement is True: _validate_autoinc(col, True) return col - elif col.autoincrement in ( - "auto", - "ignore_fk", - ) and _validate_autoinc(col, False): + elif ( + col.autoincrement + in ( + "auto", + "ignore_fk", + ) + and _validate_autoinc(col, False) + ): return col else: @@ -4519,10 +4520,7 @@ class MetaData(SchemaItem): ":class:`.DDLEvents`.", ) def append_ddl_listener(self, event_name, listener): - """Append a DDL event listener to this ``MetaData``. - - - """ + """Append a DDL event listener to this ``MetaData``.""" def adapt_listener(target, connection, **kw): tables = kw["tables"] diff --git a/lib/sqlalchemy/sql/selectable.py b/lib/sqlalchemy/sql/selectable.py index 1e73d64552..5a13444edb 100644 --- a/lib/sqlalchemy/sql/selectable.py +++ b/lib/sqlalchemy/sql/selectable.py @@ -2278,8 +2278,7 @@ class GenerativeSelect(SelectBase): @property def for_update(self): - """Provide legacy dialect support for the ``for_update`` attribute. - """ + """Provide legacy dialect support for the ``for_update`` attribute.""" if self._for_update_arg is not None: return self._for_update_arg.legacy_for_update_value else: @@ -4033,9 +4032,7 @@ class ScalarSelect(Generative, Grouping): class Exists(UnaryExpression): - """Represent an ``EXISTS`` clause. - - """ + """Represent an ``EXISTS`` clause.""" __visit_name__ = UnaryExpression.__visit_name__ _from_objects = [] diff --git a/lib/sqlalchemy/sql/sqltypes.py b/lib/sqlalchemy/sql/sqltypes.py index f6d1c49ea3..ac8e9ed060 100644 --- a/lib/sqlalchemy/sql/sqltypes.py +++ b/lib/sqlalchemy/sql/sqltypes.py @@ -2224,7 +2224,7 @@ class JSON(Indexable, TypeEngine): :attr:`.types.JSON.NULL` - """ + """ self.none_as_null = none_as_null class JSONElementType(TypeEngine): diff --git a/lib/sqlalchemy/sql/type_api.py b/lib/sqlalchemy/sql/type_api.py index 75d8b9f86e..fb7b2ec321 100644 --- a/lib/sqlalchemy/sql/type_api.py +++ b/lib/sqlalchemy/sql/type_api.py @@ -1144,10 +1144,7 @@ class TypeDecorator(SchemaEventTarget, TypeEngine): @util.memoized_property def _has_literal_processor(self): - """memoized boolean, check if process_literal_param is implemented. - - - """ + """memoized boolean, check if process_literal_param is implemented.""" return ( self.__class__.process_literal_param.__code__ diff --git a/lib/sqlalchemy/testing/assertions.py b/lib/sqlalchemy/testing/assertions.py index 74d38ad20d..2c9baf36f9 100644 --- a/lib/sqlalchemy/testing/assertions.py +++ b/lib/sqlalchemy/testing/assertions.py @@ -334,7 +334,10 @@ def assert_raises(except_cls, callable_, *args, **kw): def assert_raises_context_ok(except_cls, callable_, *args, **kw): _assert_raises( - except_cls, callable_, args, kw, + except_cls, + callable_, + args, + kw, ) @@ -369,7 +372,10 @@ def _assert_raises( if msg is not None: assert re.search( msg, util.text_type(err), re.UNICODE - ), "%r !~ %s" % (msg, err,) + ), "%r !~ %s" % ( + msg, + err, + ) if check_context and not are_we_already_in_a_traceback: _assert_proper_exception_context(err) print(util.text_type(err).encode("utf-8")) @@ -504,9 +510,12 @@ class ComparesTables(object): assert reflected_table.primary_key.columns[c.name] is not None def assert_types_base(self, c1, c2): - assert c1.type._compare_type_affinity(c2.type), ( - "On column %r, type '%s' doesn't correspond to type '%s'" - % (c1.name, c1.type, c2.type) + assert c1.type._compare_type_affinity( + c2.type + ), "On column %r, type '%s' doesn't correspond to type '%s'" % ( + c1.name, + c1.type, + c2.type, ) diff --git a/lib/sqlalchemy/testing/provision.py b/lib/sqlalchemy/testing/provision.py index 660a3bd24c..7669cdc32e 100644 --- a/lib/sqlalchemy/testing/provision.py +++ b/lib/sqlalchemy/testing/provision.py @@ -110,8 +110,7 @@ def drop_db(cfg, eng, ident): @register.init def update_db_opts(db_url, db_opts): - """Set database options (db_opts) for a test database that we created. - """ + """Set database options (db_opts) for a test database that we created.""" pass diff --git a/lib/sqlalchemy/testing/requirements.py b/lib/sqlalchemy/testing/requirements.py index df3aa4613b..0008b8c7b1 100644 --- a/lib/sqlalchemy/testing/requirements.py +++ b/lib/sqlalchemy/testing/requirements.py @@ -46,7 +46,7 @@ class SuiteRequirements(Requirements): @property def on_update_cascade(self): - """"target database must support ON UPDATE..CASCADE behavior in + """target database must support ON UPDATE..CASCADE behavior in foreign keys.""" return exclusions.open() @@ -335,7 +335,7 @@ class SuiteRequirements(Requirements): @property def implements_get_lastrowid(self): - """"target dialect implements the executioncontext.get_lastrowid() + """target dialect implements the executioncontext.get_lastrowid() method without reliance on RETURNING. """ @@ -343,7 +343,7 @@ class SuiteRequirements(Requirements): @property def emulated_lastrowid(self): - """"target dialect retrieves cursor.lastrowid, or fetches + """target dialect retrieves cursor.lastrowid, or fetches from a database-side function after an insert() construct executes, within the get_lastrowid() method. @@ -355,7 +355,7 @@ class SuiteRequirements(Requirements): @property def dbapi_lastrowid(self): - """"target platform includes a 'lastrowid' accessor on the DBAPI + """target platform includes a 'lastrowid' accessor on the DBAPI cursor object. """ @@ -376,17 +376,16 @@ class SuiteRequirements(Requirements): @property def cross_schema_fk_reflection(self): - """target system must support reflection of inter-schema foreign keys - - """ + """target system must support reflection of inter-schema foreign + keys""" return exclusions.closed() @property def implicit_default_schema(self): """target system has a strong concept of 'default' schema that can - be referred to implicitly. + be referred to implicitly. - basically, PostgreSQL. + basically, PostgreSQL. """ return exclusions.closed() @@ -464,8 +463,8 @@ class SuiteRequirements(Requirements): @property def view_reflection(self): - """target database must support inspection of the full CREATE VIEW definition. - """ + """target database must support inspection of the full CREATE VIEW + definition.""" return self.views @property @@ -563,9 +562,7 @@ class SuiteRequirements(Requirements): @property def symbol_names_w_double_quote(self): - """Target driver can create tables with a name like 'some " table' - - """ + """Target driver can create tables with a name like 'some " table'""" return exclusions.open() @property @@ -713,7 +710,7 @@ class SuiteRequirements(Requirements): @property def json_array_indexes(self): - """"target platform supports numeric array indexes + """target platform supports numeric array indexes within a JSON structure""" return self.json_type diff --git a/lib/sqlalchemy/testing/suite/test_reflection.py b/lib/sqlalchemy/testing/suite/test_reflection.py index ff9d2fd2ec..ce14b042ed 100644 --- a/lib/sqlalchemy/testing/suite/test_reflection.py +++ b/lib/sqlalchemy/testing/suite/test_reflection.py @@ -93,7 +93,10 @@ class QuotedNameArgumentTest(fixtures.TablesTest): Column("related_id", Integer), sa.PrimaryKeyConstraint("id", name="pk quote ' one"), sa.Index("ix quote ' one", "name"), - sa.UniqueConstraint("data", name="uq quote' one",), + sa.UniqueConstraint( + "data", + name="uq quote' one", + ), sa.ForeignKeyConstraint( ["id"], ["related.id"], name="fk quote ' one" ), @@ -112,7 +115,10 @@ class QuotedNameArgumentTest(fixtures.TablesTest): Column("related_id", Integer), sa.PrimaryKeyConstraint("id", name='pk quote " two'), sa.Index('ix quote " two', "name"), - sa.UniqueConstraint("data", name='uq quote" two',), + sa.UniqueConstraint( + "data", + name='uq quote" two', + ), sa.ForeignKeyConstraint( ["id"], ["related.id"], name='fk quote " two' ), @@ -1298,11 +1304,17 @@ class ComputedReflectionTest(fixtures.ComputedReflectionFixtureTest): ) if testing.requires.computed_columns_virtual.enabled: self.check_column( - data, "computed_virtual", "normal+2", False, + data, + "computed_virtual", + "normal+2", + False, ) if testing.requires.computed_columns_stored.enabled: self.check_column( - data, "computed_stored", "normal-42", True, + data, + "computed_stored", + "normal-42", + True, ) @testing.requires.schemas @@ -1322,11 +1334,17 @@ class ComputedReflectionTest(fixtures.ComputedReflectionFixtureTest): ) if testing.requires.computed_columns_virtual.enabled: self.check_column( - data, "computed_virtual", "normal/2", False, + data, + "computed_virtual", + "normal/2", + False, ) if testing.requires.computed_columns_stored.enabled: self.check_column( - data, "computed_stored", "normal*42", True, + data, + "computed_stored", + "normal*42", + True, ) diff --git a/lib/sqlalchemy/testing/suite/test_select.py b/lib/sqlalchemy/testing/suite/test_select.py index 23e66a3fae..ff0daec3ff 100644 --- a/lib/sqlalchemy/testing/suite/test_select.py +++ b/lib/sqlalchemy/testing/suite/test_select.py @@ -789,7 +789,8 @@ class IsOrIsNotDistinctFromTest(fixtures.TablesTest): tbl.select(tbl.c.col_a.is_distinct_from(tbl.c.col_b)) ).fetchall() eq_( - len(result), expected_row_count_for_is, + len(result), + expected_row_count_for_is, ) expected_row_count_for_isnot = ( @@ -799,5 +800,6 @@ class IsOrIsNotDistinctFromTest(fixtures.TablesTest): tbl.select(tbl.c.col_a.isnot_distinct_from(tbl.c.col_b)) ).fetchall() eq_( - len(result), expected_row_count_for_isnot, + len(result), + expected_row_count_for_isnot, ) diff --git a/lib/sqlalchemy/testing/suite/test_types.py b/lib/sqlalchemy/testing/suite/test_types.py index e3f362f320..9bf8b7b4af 100644 --- a/lib/sqlalchemy/testing/suite/test_types.py +++ b/lib/sqlalchemy/testing/suite/test_types.py @@ -604,9 +604,7 @@ class NumericTest(_LiteralRoundTripFixture, fixtures.TestBase): @testing.requires.precision_numerics_enotation_large def test_enotation_decimal_large(self): - """test exceedingly large decimals. - - """ + """test exceedingly large decimals.""" numbers = set( [ @@ -928,7 +926,8 @@ class JSONTest(_LiteralRoundTripFixture, fixtures.TablesTest): conn = connection conn.execute( - self.tables.data_table.insert(), {"name": "r1", "data": JSON.NULL}, + self.tables.data_table.insert(), + {"name": "r1", "data": JSON.NULL}, ) eq_( diff --git a/lib/sqlalchemy/util/compat.py b/lib/sqlalchemy/util/compat.py index c1f4988217..4ba37b5778 100644 --- a/lib/sqlalchemy/util/compat.py +++ b/lib/sqlalchemy/util/compat.py @@ -303,8 +303,7 @@ else: if py35: def _formatannotation(annotation, base_module=None): - """vendored from python 3.7 - """ + """vendored from python 3.7""" if getattr(annotation, "__module__", None) == "typing": return repr(annotation).replace("typing.", "") diff --git a/lib/sqlalchemy/util/langhelpers.py b/lib/sqlalchemy/util/langhelpers.py index 1fedda2564..ffa5e03958 100644 --- a/lib/sqlalchemy/util/langhelpers.py +++ b/lib/sqlalchemy/util/langhelpers.py @@ -66,7 +66,8 @@ class safe_reraise(object): self._exc_info = None # remove potential circular references if not self.warn_only: compat.raise_( - exc_value, with_traceback=exc_tb, + exc_value, + with_traceback=exc_tb, ) else: if not compat.py3k and self._exc_info and self._exc_info[1]: @@ -698,10 +699,10 @@ def class_hierarchy(cls): def iterate_attributes(cls): """iterate all the keys and attributes associated - with a class, without using getattr(). + with a class, without using getattr(). - Does not use getattr() so that class-sensitive - descriptors (i.e. property.__get__()) are not called. + Does not use getattr() so that class-sensitive + descriptors (i.e. property.__get__()) are not called. """ keys = dir(cls) @@ -1739,8 +1740,8 @@ def inject_param_text(doctext, inject_params): def repr_tuple_names(names): - """ Trims a list of strings from the middle and return a string of up to - four elements. Strings greater than 11 characters will be truncated""" + """Trims a list of strings from the middle and return a string of up to + four elements. Strings greater than 11 characters will be truncated""" if len(names) == 0: return None flag = len(names) <= 4 diff --git a/setup.cfg b/setup.cfg index e5e58c48b9..ff68592b8f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -13,7 +13,7 @@ sign = 1 identity = C4DAFEE1 [flake8] -show-source = true +show-source = false enable-extensions = G # E203 is due to https://github.com/PyCQA/pycodestyle/issues/373 ignore = diff --git a/test/aaa_profiling/test_zoomark_orm.py b/test/aaa_profiling/test_zoomark_orm.py index 62b154436c..71ff062500 100644 --- a/test/aaa_profiling/test_zoomark_orm.py +++ b/test/aaa_profiling/test_zoomark_orm.py @@ -31,10 +31,7 @@ Zoo = Animal = session = None class ZooMarkTest(replay_fixture.ReplayFixtureTest): - """Runs the ZooMark and squawks if method counts vary from the norm. - - - """ + """Runs the ZooMark and squawks if method counts vary from the norm.""" __requires__ = ("cpython",) __only_on__ = "postgresql+psycopg2" diff --git a/test/base/test_warnings.py b/test/base/test_warnings.py index c8807df09a..0cbab7f282 100644 --- a/test/base/test_warnings.py +++ b/test/base/test_warnings.py @@ -15,7 +15,7 @@ class WarnDeprecatedLimitedTest(fixtures.TestBase): ) def test_warn_deprecated_limited_cap(self): - """ warn_deprecated_limited() and warn_limited() use + """warn_deprecated_limited() and warn_limited() use _hash_limit_string actually just verifying that _hash_limit_string works as expected diff --git a/test/dialect/mssql/test_engine.py b/test/dialect/mssql/test_engine.py index d99799a6a4..d99fef22c5 100644 --- a/test/dialect/mssql/test_engine.py +++ b/test/dialect/mssql/test_engine.py @@ -515,7 +515,9 @@ class IsolationLevelDetectTest(fixtures.TestBase): result = [] - def fail_on_exec(stmt,): + def fail_on_exec( + stmt, + ): if view is not None and view in stmt: result.append(("SERIALIZABLE",)) else: @@ -568,7 +570,8 @@ class InvalidTransactionFalsePositiveTest(fixtures.TablesTest): @classmethod def insert_data(cls, connection): connection.execute( - cls.tables.error_t.insert(), [{"error_code": "01002"}], + cls.tables.error_t.insert(), + [{"error_code": "01002"}], ) def test_invalid_transaction_detection(self, connection): diff --git a/test/dialect/mssql/test_query.py b/test/dialect/mssql/test_query.py index bfd984ce7f..9969b84df8 100644 --- a/test/dialect/mssql/test_query.py +++ b/test/dialect/mssql/test_query.py @@ -261,9 +261,12 @@ class QueryUnicodeTest(fixtures.TestBase): ).encode("UTF-8") ) r = con.execute(t1.select()).first() - assert isinstance(r[1], util.text_type), ( - "%s is %s instead of unicode, working on %s" - % (r[1], type(r[1]), meta.bind) + assert isinstance( + r[1], util.text_type + ), "%s is %s instead of unicode, working on %s" % ( + r[1], + type(r[1]), + meta.bind, ) eq_(r[1], util.ue("abc \xc3\xa9 def")) diff --git a/test/dialect/mssql/test_reflection.py b/test/dialect/mssql/test_reflection.py index 6d74d19f70..a7718e2e1c 100644 --- a/test/dialect/mssql/test_reflection.py +++ b/test/dialect/mssql/test_reflection.py @@ -395,13 +395,11 @@ class ReflectHugeViewTest(fixtures.TestBase): for i in range(self.col_num) ] ) - self.view_str = view_str = ( - "CREATE VIEW huge_named_view AS SELECT %s FROM base_table" - % ( - ",".join( - "long_named_column_number_%d" % i - for i in range(self.col_num) - ) + self.view_str = ( + view_str + ) = "CREATE VIEW huge_named_view AS SELECT %s FROM base_table" % ( + ",".join( + "long_named_column_number_%d" % i for i in range(self.col_num) ) ) assert len(view_str) > 4000 @@ -505,7 +503,8 @@ class OwnerPlusDBTest(fixtures.TestBase): eq_(schema, expected_schema) mock_connection = mock.Mock( - dialect=dialect, scalar=mock.Mock(return_value="Some Database"), + dialect=dialect, + scalar=mock.Mock(return_value="Some Database"), ) mock_lambda = mock.Mock() base._switch_db(schema, mock_connection, mock_lambda, "x", y="bar") diff --git a/test/dialect/mssql/test_types.py b/test/dialect/mssql/test_types.py index 8c9679a70f..6ea5b48efe 100644 --- a/test/dialect/mssql/test_types.py +++ b/test/dialect/mssql/test_types.py @@ -789,7 +789,9 @@ class TypeRoundTripTest( @testing.metadata_fixture() def datetimeoffset_fixture(self, metadata): t = Table( - "test_dates", metadata, Column("adatetimeoffset", DATETIMEOFFSET), + "test_dates", + metadata, + Column("adatetimeoffset", DATETIMEOFFSET), ) return t @@ -886,7 +888,8 @@ class TypeRoundTripTest( return conn.execute( - t.insert(), adatetimeoffset=dto_param_value, + t.insert(), + adatetimeoffset=dto_param_value, ) row = conn.execute(t.select()).first() diff --git a/test/dialect/oracle/test_dialect.py b/test/dialect/oracle/test_dialect.py index 181667e63f..b077669e57 100644 --- a/test/dialect/oracle/test_dialect.py +++ b/test/dialect/oracle/test_dialect.py @@ -103,10 +103,22 @@ class EncodingErrorsTest(fixtures.TestBase): ) _oracle_char_combinations = testing.combinations( - ("STRING", cx_Oracle_STRING,), - ("FIXED_CHAR", cx_Oracle_FIXED_CHAR,), - ("CLOB", cx_Oracle_CLOB,), - ("NCLOB", cx_Oracle_NCLOB,), + ( + "STRING", + cx_Oracle_STRING, + ), + ( + "FIXED_CHAR", + cx_Oracle_FIXED_CHAR, + ), + ( + "CLOB", + cx_Oracle_CLOB, + ), + ( + "NCLOB", + cx_Oracle_NCLOB, + ), argnames="cx_oracle_type", id_="ia", ) @@ -149,7 +161,9 @@ class EncodingErrorsTest(fixtures.TestBase): @_oracle_char_combinations @testing.requires.python2 def test_encoding_errors_sqla_py2k( - self, cx_Oracle, cx_oracle_type, + self, + cx_Oracle, + cx_oracle_type, ): ignore_dialect = cx_oracle.dialect( dbapi=cx_Oracle, encoding_errors="ignore" @@ -167,7 +181,9 @@ class EncodingErrorsTest(fixtures.TestBase): @_oracle_char_combinations @testing.requires.python2 def test_no_encoding_errors_sqla_py2k( - self, cx_Oracle, cx_oracle_type, + self, + cx_Oracle, + cx_oracle_type, ): plain_dialect = cx_oracle.dialect(dbapi=cx_Oracle) @@ -183,7 +199,9 @@ class EncodingErrorsTest(fixtures.TestBase): @_oracle_char_combinations @testing.requires.python3 def test_encoding_errors_cx_oracle_py3k( - self, cx_Oracle, cx_oracle_type, + self, + cx_Oracle, + cx_oracle_type, ): ignore_dialect = cx_oracle.dialect( dbapi=cx_Oracle, encoding_errors="ignore" @@ -200,7 +218,10 @@ class EncodingErrorsTest(fixtures.TestBase): cursor.mock_calls, [ mock.call.var( - mock.ANY, None, cursor.arraysize, encodingErrors="ignore", + mock.ANY, + None, + cursor.arraysize, + encodingErrors="ignore", ) ], ) @@ -208,7 +229,9 @@ class EncodingErrorsTest(fixtures.TestBase): @_oracle_char_combinations @testing.requires.python3 def test_no_encoding_errors_cx_oracle_py3k( - self, cx_Oracle, cx_oracle_type, + self, + cx_Oracle, + cx_oracle_type, ): plain_dialect = cx_oracle.dialect(dbapi=cx_Oracle) diff --git a/test/dialect/oracle/test_reflection.py b/test/dialect/oracle/test_reflection.py index 458906b787..4ce60db4c3 100644 --- a/test/dialect/oracle/test_reflection.py +++ b/test/dialect/oracle/test_reflection.py @@ -212,7 +212,12 @@ drop synonym %(test_schema)s.local_table; ), {"text": "my table comment"}, ) - eq_(insp.get_table_comment("parent",), {"text": "my local comment"}) + eq_( + insp.get_table_comment( + "parent", + ), + {"text": "my local comment"}, + ) eq_( insp.get_table_comment( "parent", schema=testing.db.dialect.default_schema_name diff --git a/test/dialect/postgresql/test_compiler.py b/test/dialect/postgresql/test_compiler.py index 7e082166ba..1a92f6b66f 100644 --- a/test/dialect/postgresql/test_compiler.py +++ b/test/dialect/postgresql/test_compiler.py @@ -1228,7 +1228,9 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): ) self.assert_compile( - c.any(5), "%(param_1)s = ANY (x)", checkparams={"param_1": 5}, + c.any(5), + "%(param_1)s = ANY (x)", + checkparams={"param_1": 5}, ) self.assert_compile( @@ -1238,7 +1240,9 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): ) self.assert_compile( - c.all(5), "%(param_1)s = ALL (x)", checkparams={"param_1": 5}, + c.all(5), + "%(param_1)s = ALL (x)", + checkparams={"param_1": 5}, ) self.assert_compile( @@ -2216,8 +2220,7 @@ class DistinctOnTest(fixtures.TestBase, AssertsCompiledSQL): class FullTextSearchTest(fixtures.TestBase, AssertsCompiledSQL): - """Tests for full text searching - """ + """Tests for full text searching""" __dialect__ = postgresql.dialect() @@ -2238,8 +2241,8 @@ class FullTextSearchTest(fixtures.TestBase, AssertsCompiledSQL): def _raise_query(self, q): """ - useful for debugging. just do... - self._raise_query(q) + useful for debugging. just do... + self._raise_query(q) """ c = q.compile(dialect=postgresql.dialect()) raise ValueError(c) diff --git a/test/dialect/postgresql/test_reflection.py b/test/dialect/postgresql/test_reflection.py index d7f5b5381c..b92d46c7be 100644 --- a/test/dialect/postgresql/test_reflection.py +++ b/test/dialect/postgresql/test_reflection.py @@ -877,8 +877,7 @@ class ReflectionTest(fixtures.TestBase): @testing.provide_metadata def test_index_reflection(self): - """ Reflecting partial & expression-based indexes should warn - """ + """Reflecting partial & expression-based indexes should warn""" metadata = self.metadata diff --git a/test/dialect/postgresql/test_types.py b/test/dialect/postgresql/test_types.py index 9735540ee4..4aa85cc926 100644 --- a/test/dialect/postgresql/test_types.py +++ b/test/dialect/postgresql/test_types.py @@ -1880,7 +1880,10 @@ class ArrayEnum(fixtures.TestBase): c = "ccc" tbl.append_column( - Column("pyenum_col", array_cls(enum_cls(MyEnum)),), + Column( + "pyenum_col", + array_cls(enum_cls(MyEnum)), + ), ) self.metadata.create_all(connection) @@ -1917,7 +1920,10 @@ class ArrayJSON(fixtures.TestBase): "json_table", self.metadata, Column("id", Integer, primary_key=True), - Column("json_col", array_cls(json_cls),), + Column( + "json_col", + array_cls(json_cls), + ), ) self.metadata.create_all(connection) diff --git a/test/dialect/test_sqlite.py b/test/dialect/test_sqlite.py index c6ac94aeb6..46ff6c9e7a 100644 --- a/test/dialect/test_sqlite.py +++ b/test/dialect/test_sqlite.py @@ -65,9 +65,7 @@ class TestTypes(fixtures.TestBase, AssertsExecutionResults): __only_on__ = "sqlite" def test_boolean(self): - """Test that the boolean only treats 1 as True - - """ + """Test that the boolean only treats 1 as True""" meta = MetaData(testing.db) t = Table( @@ -604,7 +602,7 @@ class DialectTest( 'true', 'false', and 'column' are undocumented reserved words when used as column identifiers (as of 3.5.1). Covering them here to ensure they remain in place if the dialect's - reserved_words set is updated in the future. """ + reserved_words set is updated in the future.""" meta = MetaData(testing.db) t = Table( @@ -654,7 +652,7 @@ class DialectTest( @testing.provide_metadata def test_quoted_identifiers_functional_two(self): - """"test the edgiest of edge cases, quoted table/col names + """ "test the edgiest of edge cases, quoted table/col names that start and end with quotes. SQLite claims to have fixed this in diff --git a/test/engine/test_deprecations.py b/test/engine/test_deprecations.py index 8bae599a9d..39b8aee384 100644 --- a/test/engine/test_deprecations.py +++ b/test/engine/test_deprecations.py @@ -1729,7 +1729,7 @@ class ExplicitAutoCommitDeprecatedTest(fixtures.TestBase): """test the 'autocommit' flag on select() and text() objects. Requires PostgreSQL so that we may define a custom function which - modifies the database. """ + modifies the database.""" __only_on__ = "postgresql" diff --git a/test/engine/test_reflection.py b/test/engine/test_reflection.py index fef8363cfb..b31be17629 100644 --- a/test/engine/test_reflection.py +++ b/test/engine/test_reflection.py @@ -101,7 +101,9 @@ class ReflectionTest(fixtures.TestBase, ComparesTables): self.assert_tables_equal(addresses, reflected_addresses) @testing.provide_metadata - def test_autoload_with_imply_autoload(self,): + def test_autoload_with_imply_autoload( + self, + ): meta = self.metadata t = Table( "t", @@ -880,7 +882,7 @@ class ReflectionTest(fixtures.TestBase, ComparesTables): def test_override_existing_fk(self): """test that you can override columns and specify new foreign keys to other reflected tables, on columns which *do* already - have that foreign key, and that the FK is not duped. """ + have that foreign key, and that the FK is not duped.""" meta = self.metadata Table( @@ -2293,9 +2295,15 @@ class ComputedColumnTest(fixtures.ComputedReflectionFixtureTest): ) if testing.requires.computed_columns_virtual.enabled: self.check_table_column( - table, "computed_virtual", "normal+2", False, + table, + "computed_virtual", + "normal+2", + False, ) if testing.requires.computed_columns_stored.enabled: self.check_table_column( - table, "computed_stored", "normal-42", True, + table, + "computed_stored", + "normal-42", + True, ) diff --git a/test/engine/test_transaction.py b/test/engine/test_transaction.py index 6ca018df84..d59d8b31bb 100644 --- a/test/engine/test_transaction.py +++ b/test/engine/test_transaction.py @@ -787,7 +787,7 @@ class ExplicitAutoCommitTest(fixtures.TestBase): """test the 'autocommit' flag on select() and text() objects. Requires PostgreSQL so that we may define a custom function which - modifies the database. """ + modifies the database.""" __only_on__ = "postgresql" diff --git a/test/ext/declarative/test_inheritance.py b/test/ext/declarative/test_inheritance.py index aba6d41915..e8db1e9599 100644 --- a/test/ext/declarative/test_inheritance.py +++ b/test/ext/declarative/test_inheritance.py @@ -894,9 +894,7 @@ class DeclarativeInheritanceTest(DeclarativeTestBase): ) def test_columns_single_inheritance_cascading_resolution_pk(self): - """An additional test for #4352 in terms of the requested use case. - - """ + """An additional test for #4352 in terms of the requested use case.""" class TestBase(Base): __abstract__ = True diff --git a/test/ext/test_associationproxy.py b/test/ext/test_associationproxy.py index 41d1bdd45e..a1d707ccd2 100644 --- a/test/ext/test_associationproxy.py +++ b/test/ext/test_associationproxy.py @@ -3176,7 +3176,10 @@ class MultiOwnerTest( self._assert_raises_ambiguous(lambda: D.c_data == 5) def test_rel_expressions_not_available(self): - B, D, = self.classes("B", "D") + ( + B, + D, + ) = self.classes("B", "D") self._assert_raises_ambiguous(lambda: D.c_data.any(B.id == 5)) diff --git a/test/ext/test_horizontal_shard.py b/test/ext/test_horizontal_shard.py index a3d1d957fa..75dabf64fc 100644 --- a/test/ext/test_horizontal_shard.py +++ b/test/ext/test_horizontal_shard.py @@ -464,8 +464,7 @@ class AttachedFileShardTest(ShardTest, fixtures.TestBase): class SelectinloadRegressionTest(fixtures.DeclarativeMappedTest): - """test #4175 - """ + """test #4175""" @classmethod def setup_classes(cls): diff --git a/test/orm/_fixtures.py b/test/orm/_fixtures.py index 2b4fca1489..3c4acf4bbf 100644 --- a/test/orm/_fixtures.py +++ b/test/orm/_fixtures.py @@ -15,9 +15,7 @@ __all__ = () class FixtureTest(fixtures.MappedTest): - """A MappedTest pre-configured with a common set of fixtures. - - """ + """A MappedTest pre-configured with a common set of fixtures.""" run_define_tables = "once" run_setup_classes = "once" diff --git a/test/orm/inheritance/test_basic.py b/test/orm/inheritance/test_basic.py index a94f82cd25..9c131591a6 100644 --- a/test/orm/inheritance/test_basic.py +++ b/test/orm/inheritance/test_basic.py @@ -893,8 +893,7 @@ class PolymorphicAttributeManagementTest(fixtures.MappedTest): ) def test_entirely_oob_assignment(self): - """test warn on an unknown polymorphic identity. - """ + """test warn on an unknown polymorphic identity.""" B = self.classes.B sess = Session() @@ -2533,7 +2532,7 @@ class OptimizedLoadTest(fixtures.MappedTest): ) def test_optimized_passes(self): - """"test that the 'optimized load' routine doesn't crash when + """ "test that the 'optimized load' routine doesn't crash when a column in the join condition is not available.""" base, sub = self.tables.base, self.tables.sub diff --git a/test/orm/inheritance/test_polymorphic_rel.py b/test/orm/inheritance/test_polymorphic_rel.py index ad9b570150..544da404ff 100644 --- a/test/orm/inheritance/test_polymorphic_rel.py +++ b/test/orm/inheritance/test_polymorphic_rel.py @@ -1395,7 +1395,8 @@ class _PolymorphicTestBase(object): ("vlad", "Elbonia, Inc."), ] eq_( - q(self, sess).all(), expected, + q(self, sess).all(), + expected, ) def test_mixed_entities_two(self): diff --git a/test/orm/inheritance/test_productspec.py b/test/orm/inheritance/test_productspec.py index aab3570c9d..9516ed4319 100644 --- a/test/orm/inheritance/test_productspec.py +++ b/test/orm/inheritance/test_productspec.py @@ -325,7 +325,7 @@ class InheritTest(fixtures.MappedTest): """this tests the RasterDocument being attached to the Assembly, but *not* the Document. this means only a "sub-class" task, i.e. corresponding to an inheriting mapper but not the base mapper, - is created. """ + is created.""" product_mapper = mapper( Product, diff --git a/test/orm/inheritance/test_relationship.py b/test/orm/inheritance/test_relationship.py index 48c71209f0..59087ec1be 100644 --- a/test/orm/inheritance/test_relationship.py +++ b/test/orm/inheritance/test_relationship.py @@ -1351,9 +1351,7 @@ class SameNamedPropTwoPolymorphicSubClassesTest(fixtures.MappedTest): class SubClassToSubClassFromParentTest(fixtures.MappedTest): - """test #2617 - - """ + """test #2617""" run_setup_classes = "once" run_setup_mappers = "once" diff --git a/test/orm/test_attributes.py b/test/orm/test_attributes.py index 49e3ecb8ef..2d5829ed29 100644 --- a/test/orm/test_attributes.py +++ b/test/orm/test_attributes.py @@ -575,7 +575,7 @@ class AttributesTest(fixtures.ORMTest): def test_lazytrackparent(self): """test that the "hasparent" flag works properly - when lazy loaders and backrefs are used + when lazy loaders and backrefs are used """ @@ -837,7 +837,7 @@ class AttributesTest(fixtures.ORMTest): """changeset: 1633 broke ability to use ORM to map classes with unusual descriptor attributes (for example, classes that inherit from ones implementing zope.interface.Interface). This is a - simple regression test to prevent that defect. """ + simple regression test to prevent that defect.""" class des(object): def __get__(self, instance, owner): @@ -1093,7 +1093,7 @@ class UtilTest(fixtures.ORMTest): def test_set_commited_value_none_uselist(self): """test that set_committed_value->None to a uselist generates an - empty list """ + empty list""" class Foo(object): pass diff --git a/test/orm/test_cascade.py b/test/orm/test_cascade.py index e726551ab7..114759a0bd 100644 --- a/test/orm/test_cascade.py +++ b/test/orm/test_cascade.py @@ -3619,8 +3619,8 @@ class O2MConflictTest(fixtures.MappedTest): class PartialFlushTest(fixtures.MappedTest): - """test cascade behavior as it relates to object lists passed to flush(). - """ + """test cascade behavior as it relates to object lists passed to + flush().""" @classmethod def define_tables(cls, metadata): diff --git a/test/orm/test_cycles.py b/test/orm/test_cycles.py index 7dd349a74a..dd40630300 100644 --- a/test/orm/test_cycles.py +++ b/test/orm/test_cycles.py @@ -1162,10 +1162,7 @@ class OneToManyManyToOneTest(fixtures.MappedTest): class SelfReferentialPostUpdateTest(fixtures.MappedTest): - """Post_update on a single self-referential mapper. - - - """ + """Post_update on a single self-referential mapper.""" @classmethod def define_tables(cls, metadata): @@ -1502,8 +1499,8 @@ class SelfReferentialPostUpdateTest3(fixtures.MappedTest): class PostUpdateBatchingTest(fixtures.MappedTest): - """test that lots of post update cols batch together into a single UPDATE. - """ + """test that lots of post update cols batch together into a single + UPDATE.""" @classmethod def define_tables(cls, metadata): diff --git a/test/orm/test_defaults.py b/test/orm/test_defaults.py index 4184483e84..2c87a47590 100644 --- a/test/orm/test_defaults.py +++ b/test/orm/test_defaults.py @@ -309,7 +309,10 @@ class ComputedDefaultsOnUpdateTest(fixtures.MappedTest): True, testing.requires.computed_columns_on_update_returning, ), - ("noneagerload", False,), + ( + "noneagerload", + False, + ), id_="ia", ) def test_update_computed(self, eager): diff --git a/test/orm/test_deferred.py b/test/orm/test_deferred.py index 28d771234e..f8817bbd76 100644 --- a/test/orm/test_deferred.py +++ b/test/orm/test_deferred.py @@ -268,8 +268,8 @@ class DeferredTest(AssertsCompiledSQL, _fixtures.FixtureTest): self.sql_count_(0, go) def test_preserve_changes(self): - """A deferred load operation doesn't revert modifications on attributes - """ + """A deferred load operation doesn't revert modifications on + attributes""" orders, Order = self.tables.orders, self.classes.Order @@ -821,7 +821,7 @@ class DeferredOptionsTest(AssertsCompiledSQL, _fixtures.FixtureTest): def test_locates_col(self): """changed in 1.0 - we don't search for deferred cols in the result - now. """ + now.""" orders, Order = self.tables.orders, self.classes.Order diff --git a/test/orm/test_deprecations.py b/test/orm/test_deprecations.py index 4cc75eca85..156898fced 100644 --- a/test/orm/test_deprecations.py +++ b/test/orm/test_deprecations.py @@ -2237,7 +2237,7 @@ class NonPrimaryRelationshipLoaderTest(_fixtures.FixtureTest): def test_selectload(self): """tests lazy loading with two relationships simultaneously, - from the same table, using aliases. """ + from the same table, using aliases.""" users, orders, User, Address, Order, addresses = ( self.tables.users, @@ -2288,7 +2288,7 @@ class NonPrimaryRelationshipLoaderTest(_fixtures.FixtureTest): def test_joinedload(self): """Eager loading with two relationships simultaneously, - from the same table, using aliases.""" + from the same table, using aliases.""" users, orders, User, Address, Order, addresses = ( self.tables.users, diff --git a/test/orm/test_eager_relations.py b/test/orm/test_eager_relations.py index b7909a8e9c..eebf4f115b 100644 --- a/test/orm/test_eager_relations.py +++ b/test/orm/test_eager_relations.py @@ -221,7 +221,7 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL): def test_orderby_related(self): """A regular mapper select on a single table can - order by a relationship to a second table""" + order by a relationship to a second table""" Address, addresses, users, User = ( self.classes.Address, @@ -714,7 +714,7 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL): def test_double_w_ac(self): """Eager loading with two relationships simultaneously, - from the same table, using aliases.""" + from the same table, using aliases.""" ( users, @@ -788,7 +788,7 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL): def test_double_w_ac_against_subquery(self): """Eager loading with two relationships simultaneously, - from the same table, using aliases.""" + from the same table, using aliases.""" ( users, diff --git a/test/orm/test_events.py b/test/orm/test_events.py index 54ad88a20e..e76cba03ba 100644 --- a/test/orm/test_events.py +++ b/test/orm/test_events.py @@ -766,7 +766,7 @@ class DeclarativeEventListenTest( class DeferredMapperEventsTest(_RemoveListeners, _fixtures.FixtureTest): - """"test event listeners against unmapped classes. + """ "test event listeners against unmapped classes. This incurs special logic. Note if we ever do the "remove" case, it has to get all of these, too. diff --git a/test/orm/test_expire.py b/test/orm/test_expire.py index fafaba4842..b8b0baa6dc 100644 --- a/test/orm/test_expire.py +++ b/test/orm/test_expire.py @@ -1069,8 +1069,8 @@ class ExpireTest(_fixtures.FixtureTest): eq_(len(list(sess)), 9) def test_state_change_col_to_deferred(self): - """Behavioral test to verify the current activity of loader callables - """ + """Behavioral test to verify the current activity of loader + callables""" users, User = self.tables.users, self.classes.User @@ -1117,8 +1117,8 @@ class ExpireTest(_fixtures.FixtureTest): assert "name" not in attributes.instance_state(u1).callables def test_state_deferred_to_col(self): - """Behavioral test to verify the current activity of loader callables - """ + """Behavioral test to verify the current activity of loader + callables""" users, User = self.tables.users, self.classes.User @@ -1157,8 +1157,8 @@ class ExpireTest(_fixtures.FixtureTest): assert "name" not in attributes.instance_state(u1).callables def test_state_noload_to_lazy(self): - """Behavioral test to verify the current activity of loader callables - """ + """Behavioral test to verify the current activity of loader + callables""" users, Address, addresses, User = ( self.tables.users, diff --git a/test/orm/test_joins.py b/test/orm/test_joins.py index 845c6e6f24..fdc26aba1d 100644 --- a/test/orm/test_joins.py +++ b/test/orm/test_joins.py @@ -771,7 +771,10 @@ class JoinTest(QueryTest, AssertsCompiledSQL): ) def test_single_prop_4(self): - Order, User, = (self.classes.Order, self.classes.User) + ( + Order, + User, + ) = (self.classes.Order, self.classes.User) sess = create_session() oalias1 = aliased(Order) @@ -787,7 +790,10 @@ class JoinTest(QueryTest, AssertsCompiledSQL): ) def test_single_prop_5(self): - Order, User, = (self.classes.Order, self.classes.User) + ( + Order, + User, + ) = (self.classes.Order, self.classes.User) sess = create_session() self.assert_compile( @@ -829,7 +835,10 @@ class JoinTest(QueryTest, AssertsCompiledSQL): ) def test_single_prop_8(self): - Order, User, = (self.classes.Order, self.classes.User) + ( + Order, + User, + ) = (self.classes.Order, self.classes.User) sess = create_session() # same as before using an aliased() for User as well diff --git a/test/orm/test_merge.py b/test/orm/test_merge.py index 2317ec8cec..7c96c93bd0 100644 --- a/test/orm/test_merge.py +++ b/test/orm/test_merge.py @@ -770,7 +770,7 @@ class MergeTest(_fixtures.FixtureTest): def test_no_relationship_cascade(self): """test that merge doesn't interfere with a relationship() - target that specifically doesn't include 'merge' cascade. + target that specifically doesn't include 'merge' cascade. """ Address, addresses, users, User = ( diff --git a/test/orm/test_naturalpks.py b/test/orm/test_naturalpks.py index d7a4b0fab4..b13ab00057 100644 --- a/test/orm/test_naturalpks.py +++ b/test/orm/test_naturalpks.py @@ -266,10 +266,13 @@ class NaturalPKTest(fixtures.MappedTest): # test passive_updates=True; update user self.assert_sql_count(testing.db, go, 1) sess.expunge_all() - assert User( - username="jack", - addresses=[Address(username="jack"), Address(username="jack")], - ) == sess.query(User).get("jack") + assert ( + User( + username="jack", + addresses=[Address(username="jack"), Address(username="jack")], + ) + == sess.query(User).get("jack") + ) u1 = sess.query(User).get("jack") u1.addresses = [] @@ -1117,10 +1120,13 @@ class NonPKCascadeTest(fixtures.MappedTest): # test passive_updates=True; update user self.assert_sql_count(testing.db, go, 1) sess.expunge_all() - assert User( - username="jack", - addresses=[Address(username="jack"), Address(username="jack")], - ) == sess.query(User).get(u1.id) + assert ( + User( + username="jack", + addresses=[Address(username="jack"), Address(username="jack")], + ) + == sess.query(User).get(u1.id) + ) sess.expunge_all() u1 = sess.query(User).get(u1.id) diff --git a/test/orm/test_of_type.py b/test/orm/test_of_type.py index bf7ee28286..0cb9b7d1a2 100644 --- a/test/orm/test_of_type.py +++ b/test/orm/test_of_type.py @@ -770,7 +770,10 @@ class SubclassRelationshipTest( ) def test_any_walias(self): - DataContainer, Job, = (self.classes.DataContainer, self.classes.Job) + ( + DataContainer, + Job, + ) = (self.classes.DataContainer, self.classes.Job) Job_A = aliased(Job) @@ -860,7 +863,10 @@ class SubclassRelationshipTest( ) def test_join_walias(self): - DataContainer, Job, = (self.classes.DataContainer, self.classes.Job) + ( + DataContainer, + Job, + ) = (self.classes.DataContainer, self.classes.Job) Job_A = aliased(Job) diff --git a/test/orm/test_query.py b/test/orm/test_query.py index eb27e03945..40ec724eec 100644 --- a/test/orm/test_query.py +++ b/test/orm/test_query.py @@ -2831,15 +2831,11 @@ class FilterTest(QueryTest, AssertsCompiledSQL): ).all() # test that the contents are not adapted by the aliased join - assert ( - [User(id=7), User(id=8)] - == sess.query(User) - .join("addresses", aliased=True) - .filter( - ~User.addresses.any(Address.email_address == "fred@fred.com") - ) - .all() - ) + assert [User(id=7), User(id=8)] == sess.query(User).join( + "addresses", aliased=True + ).filter( + ~User.addresses.any(Address.email_address == "fred@fred.com") + ).all() assert [User(id=10)] == sess.query(User).outerjoin( "addresses", aliased=True @@ -2853,15 +2849,11 @@ class FilterTest(QueryTest, AssertsCompiledSQL): sess = create_session() # test that any() doesn't overcorrelate - assert ( - [User(id=7), User(id=8)] - == sess.query(User) - .join("addresses") - .filter( - ~User.addresses.any(Address.email_address == "fred@fred.com") - ) - .all() - ) + assert [User(id=7), User(id=8)] == sess.query(User).join( + "addresses" + ).filter( + ~User.addresses.any(Address.email_address == "fred@fred.com") + ).all() def test_has(self): # see also HasAnyTest, a newer suite which tests these at the level of @@ -2877,41 +2869,40 @@ class FilterTest(QueryTest, AssertsCompiledSQL): Address.user.has(name="fred") ).all() - assert ( - [Address(id=2), Address(id=3), Address(id=4), Address(id=5)] - == sess.query(Address) - .filter(Address.user.has(User.name.like("%ed%"))) - .order_by(Address.id) - .all() - ) + assert [ + Address(id=2), + Address(id=3), + Address(id=4), + Address(id=5), + ] == sess.query(Address).filter( + Address.user.has(User.name.like("%ed%")) + ).order_by( + Address.id + ).all() - assert ( - [Address(id=2), Address(id=3), Address(id=4)] - == sess.query(Address) - .filter(Address.user.has(User.name.like("%ed%"), id=8)) - .order_by(Address.id) - .all() - ) + assert [Address(id=2), Address(id=3), Address(id=4)] == sess.query( + Address + ).filter(Address.user.has(User.name.like("%ed%"), id=8)).order_by( + Address.id + ).all() # test has() doesn't overcorrelate - assert ( - [Address(id=2), Address(id=3), Address(id=4)] - == sess.query(Address) - .join("user") - .filter(Address.user.has(User.name.like("%ed%"), id=8)) - .order_by(Address.id) - .all() - ) + assert [Address(id=2), Address(id=3), Address(id=4)] == sess.query( + Address + ).join("user").filter( + Address.user.has(User.name.like("%ed%"), id=8) + ).order_by( + Address.id + ).all() # test has() doesn't get subquery contents adapted by aliased join - assert ( - [Address(id=2), Address(id=3), Address(id=4)] - == sess.query(Address) - .join("user", aliased=True) - .filter(Address.user.has(User.name.like("%ed%"), id=8)) - .order_by(Address.id) - .all() - ) + assert [Address(id=2), Address(id=3), Address(id=4)] == sess.query( + Address + ).join("user", aliased=True).filter( + Address.user.has(User.name.like("%ed%"), id=8) + ).order_by( + Address.id + ).all() dingaling = sess.query(Dingaling).get(2) assert [User(id=9)] == sess.query(User).filter( @@ -3436,7 +3427,7 @@ class SetOpsTest(QueryTest, AssertsCompiledSQL): def test_union_literal_expressions_compile(self): """test that column expressions translate during - the _from_statement() portion of union(), others""" + the _from_statement() portion of union(), others""" User = self.classes.User @@ -3628,25 +3619,20 @@ class AggregateTest(QueryTest): User, Address = self.classes.User, self.classes.Address sess = create_session() - assert ( - [User(name="ed", id=8)] - == sess.query(User) - .order_by(User.id) - .group_by(User) - .join("addresses") - .having(func.count(Address.id) > 2) - .all() - ) + assert [User(name="ed", id=8)] == sess.query(User).order_by( + User.id + ).group_by(User).join("addresses").having( + func.count(Address.id) > 2 + ).all() - assert ( - [User(name="jack", id=7), User(name="fred", id=9)] - == sess.query(User) - .order_by(User.id) - .group_by(User) - .join("addresses") - .having(func.count(Address.id) < 2) - .all() - ) + assert [ + User(name="jack", id=7), + User(name="fred", id=9), + ] == sess.query(User).order_by(User.id).group_by(User).join( + "addresses" + ).having( + func.count(Address.id) < 2 + ).all() class ExistsTest(QueryTest, AssertsCompiledSQL): diff --git a/test/orm/test_relationships.py b/test/orm/test_relationships.py index 0ac0c172a9..fb55919184 100644 --- a/test/orm/test_relationships.py +++ b/test/orm/test_relationships.py @@ -2354,7 +2354,7 @@ class JoinConditionErrorTest(fixtures.TestBase): class TypeMatchTest(fixtures.MappedTest): """test errors raised when trying to add items - whose type is not handled by a relationship""" + whose type is not handled by a relationship""" @classmethod def define_tables(cls, metadata): @@ -3079,7 +3079,9 @@ class ViewOnlySyncBackref(fixtures.MappedTest): return mapper( - A, self.tables.t1, properties={"bs": rel()}, + A, + self.tables.t1, + properties={"bs": rel()}, ) mapper(B, self.tables.t2) @@ -3623,9 +3625,7 @@ class ViewOnlyComplexJoin(_RelationshipErrors, fixtures.MappedTest): class FunctionAsPrimaryJoinTest(fixtures.DeclarativeMappedTest): - """test :ticket:`3831` - - """ + """test :ticket:`3831`""" __only_on__ = "sqlite" diff --git a/test/orm/test_selectin_relations.py b/test/orm/test_selectin_relations.py index f4c17b482b..f3e7bfcca2 100644 --- a/test/orm/test_selectin_relations.py +++ b/test/orm/test_selectin_relations.py @@ -435,7 +435,7 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL): def test_orderby_related(self): """A regular mapper select on a single table can - order by a relationship to a second table""" + order by a relationship to a second table""" Address, addresses, users, User = ( self.classes.Address, diff --git a/test/orm/test_subquery_relations.py b/test/orm/test_subquery_relations.py index 825375d060..d882d8deed 100644 --- a/test/orm/test_subquery_relations.py +++ b/test/orm/test_subquery_relations.py @@ -433,7 +433,7 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL): def test_orderby_related(self): """A regular mapper select on a single table can - order by a relationship to a second table""" + order by a relationship to a second table""" Address, addresses, users, User = ( self.classes.Address, diff --git a/test/orm/test_unitofwork.py b/test/orm/test_unitofwork.py index 6e68b58996..4e4a7777ce 100644 --- a/test/orm/test_unitofwork.py +++ b/test/orm/test_unitofwork.py @@ -3488,7 +3488,9 @@ class EnsurePKSortableTest(fixtures.MappedTest): ) assert_raises_message( - sa.exc.InvalidRequestError, message, s.flush, + sa.exc.InvalidRequestError, + message, + s.flush, ) else: s.flush() diff --git a/test/requirements.py b/test/requirements.py index 3f83ca967c..55d491eb13 100644 --- a/test/requirements.py +++ b/test/requirements.py @@ -459,16 +459,16 @@ class DefaultRequirements(SuiteRequirements): @property def cross_schema_fk_reflection(self): - """target system must support reflection of inter-schema foreign keys - """ + """target system must support reflection of inter-schema foreign + keys""" return only_on(["postgresql", "mysql", "mssql"]) @property def implicit_default_schema(self): """target system has a strong concept of 'default' schema that can - be referred to implicitly. + be referred to implicitly. - basically, PostgreSQL. + basically, PostgreSQL. """ return only_on(["postgresql"]) @@ -795,9 +795,7 @@ class DefaultRequirements(SuiteRequirements): @property def symbol_names_w_double_quote(self): - """Target driver can create tables with a name like 'some " table' - - """ + """Target driver can create tables with a name like 'some " table'""" return skip_if( [no_support("oracle", "ORA-03001: unimplemented feature")] @@ -805,7 +803,7 @@ class DefaultRequirements(SuiteRequirements): @property def emulated_lastrowid(self): - """"target dialect retrieves cursor.lastrowid or an equivalent + """ "target dialect retrieves cursor.lastrowid or an equivalent after an insert() construct executes. """ return fails_on_everything_except( @@ -818,7 +816,7 @@ class DefaultRequirements(SuiteRequirements): @property def dbapi_lastrowid(self): - """"target backend includes a 'lastrowid' accessor on the DBAPI + """ "target backend includes a 'lastrowid' accessor on the DBAPI cursor object. """ diff --git a/test/sql/test_compiler.py b/test/sql/test_compiler.py index 2b02530984..20ab18f424 100644 --- a/test/sql/test_compiler.py +++ b/test/sql/test_compiler.py @@ -559,9 +559,7 @@ class SelectTest(fixtures.TestBase, AssertsCompiledSQL): eq_(s.positiontup, ["a", "b", "c"]) def test_nested_label_targeting(self): - """test nested anonymous label generation. - - """ + """test nested anonymous label generation.""" s1 = table1.select() s2 = s1.alias() s3 = select([s2], use_labels=True) @@ -2959,7 +2957,7 @@ class BindParameterTest(AssertsCompiledSQL, fixtures.TestBase): def _test_binds_no_hash_collision(self): """test that construct_params doesn't corrupt dict - due to hash collisions""" + due to hash collisions""" total_params = 100000 @@ -4088,7 +4086,11 @@ class SchemaTest(fixtures.TestBase, AssertsCompiledSQL): { "anotherid": ( "anotherid", - (t1.c.anotherid, "anotherid", "anotherid",), + ( + t1.c.anotherid, + "anotherid", + "anotherid", + ), t1.c.anotherid.type, ) }, diff --git a/test/sql/test_cte.py b/test/sql/test_cte.py index 5639ec35cb..179f751c7a 100644 --- a/test/sql/test_cte.py +++ b/test/sql/test_cte.py @@ -275,9 +275,7 @@ 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, diff --git a/test/sql/test_defaults.py b/test/sql/test_defaults.py index f72f446798..7d813e8b23 100644 --- a/test/sql/test_defaults.py +++ b/test/sql/test_defaults.py @@ -250,7 +250,12 @@ class DefaultObjectTest(fixtures.TestBase): Column("boolcol1", sa.Boolean, default=True), Column("boolcol2", sa.Boolean, default=False), # python function which uses ExecutionContext - Column("col7", Integer, default=lambda: 5, onupdate=lambda: 10,), + Column( + "col7", + Integer, + default=lambda: 5, + onupdate=lambda: 10, + ), # python builtin Column( "col8", diff --git a/test/sql/test_metadata.py b/test/sql/test_metadata.py index d8d7c4ad9d..5e1fdbddf2 100644 --- a/test/sql/test_metadata.py +++ b/test/sql/test_metadata.py @@ -729,7 +729,11 @@ class MetaDataTest(fixtures.TestBase, ComparesTables): "Column('foo', Integer(), table=None, primary_key=True, " "nullable=False, onupdate=%s, default=%s, server_default=%s, " "comment='foo')" - % (ColumnDefault(1), ColumnDefault(42), DefaultClause("42"),), + % ( + ColumnDefault(1), + ColumnDefault(42), + DefaultClause("42"), + ), ), ( Table("bar", MetaData(), Column("x", String)), @@ -5155,7 +5159,8 @@ class CopyDialectOptionsTest(fixtures.TestBase): @classmethod def check_dialect_options_(cls, t): eq_( - t.dialect_kwargs["copydialectoptionstest_some_table_arg"], "a1", + t.dialect_kwargs["copydialectoptionstest_some_table_arg"], + "a1", ) eq_( t.c.foo.dialect_kwargs["copydialectoptionstest_some_column_arg"], @@ -5198,7 +5203,9 @@ class CopyDialectOptionsTest(fixtures.TestBase): copydialectoptionstest_some_table_arg="a1", ) Index( - "idx", t1.c.foo, copydialectoptionstest_some_index_arg="a4", + "idx", + t1.c.foo, + copydialectoptionstest_some_index_arg="a4", ) self.check_dialect_options_(t1) diff --git a/test/sql/test_operators.py b/test/sql/test_operators.py index e3224084dc..1a7411d873 100644 --- a/test/sql/test_operators.py +++ b/test/sql/test_operators.py @@ -995,8 +995,7 @@ class BooleanEvalTest(fixtures.TestBase, testing.AssertsCompiledSQL): class ConjunctionTest(fixtures.TestBase, testing.AssertsCompiledSQL): - """test interaction of and_()/or_() with boolean , null constants - """ + """test interaction of and_()/or_() with boolean , null constants""" __dialect__ = default.DefaultDialect(supports_native_boolean=True) diff --git a/test/sql/test_resultset.py b/test/sql/test_resultset.py index 41dbc4838b..550c0ddcb9 100644 --- a/test/sql/test_resultset.py +++ b/test/sql/test_resultset.py @@ -1476,7 +1476,8 @@ class PositionalTextTest(fixtures.TablesTest): @classmethod def insert_data(cls, connection): connection.execute( - cls.tables.text1.insert(), [dict(a="a1", b="b1", c="c1", d="d1")], + cls.tables.text1.insert(), + [dict(a="a1", b="b1", c="c1", d="d1")], ) def test_via_column(self): diff --git a/test/sql/test_sequences.py b/test/sql/test_sequences.py index 9f16576a2f..3df92a1790 100644 --- a/test/sql/test_sequences.py +++ b/test/sql/test_sequences.py @@ -123,14 +123,14 @@ class LegacySequenceExecTest(fixtures.TestBase): def test_explicit_optional(self): """test dialect executes a Sequence, returns nextval, whether - or not "optional" is set """ + or not "optional" is set""" s = Sequence("my_sequence", optional=True) self._assert_seq_result(s.execute(testing.db)) def test_func_implicit_connectionless_execute(self): """test func.next_value().execute()/.scalar() works - with connectionless execution. """ + with connectionless execution.""" s = Sequence("my_sequence", metadata=MetaData(testing.db)) self._assert_seq_result(s.next_value().execute().scalar()) @@ -177,21 +177,21 @@ class SequenceExecTest(fixtures.TestBase): def test_execute_optional(self, connection): """test dialect executes a Sequence, returns nextval, whether - or not "optional" is set """ + or not "optional" is set""" s = Sequence("my_sequence", optional=True) self._assert_seq_result(connection.execute(s)) def test_execute_next_value(self, connection): """test func.next_value().execute()/.scalar() works - with connectionless execution. """ + with connectionless execution.""" s = Sequence("my_sequence") self._assert_seq_result(connection.scalar(s.next_value())) def test_execute_optional_next_value(self, connection): """test func.next_value().execute()/.scalar() works - with connectionless execution. """ + with connectionless execution.""" s = Sequence("my_sequence", optional=True) self._assert_seq_result(connection.scalar(s.next_value())) @@ -521,7 +521,8 @@ class SequenceAsServerDefaultTest( ) eq_( - connection.execute("select id from t_seq_test_2").scalar(), 1, + connection.execute("select id from t_seq_test_2").scalar(), + 1, ) def test_default_core_server_only(self, connection):