From: Federico Caselli Date: Tue, 6 Feb 2024 18:44:47 +0000 (+0100) Subject: remove unnecessary string concat in same line X-Git-Tag: rel_2_0_26~6^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eb2cf783855477a6d0808a318b1ce039b28e52a0;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git remove unnecessary string concat in same line manually update the files to remove literal string concat on the same line, since black does not seem to be making progress in handling these Change-Id: I3c651374c5f3db5b8bc0c700328d67ca03743b7b (cherry picked from commit 3fbbe8d67b8b193dcf715905392b1c8f33e68f35) --- diff --git a/doc/build/changelog/migration_11.rst b/doc/build/changelog/migration_11.rst index 8a1ba3ba0e..15ef6fcd0c 100644 --- a/doc/build/changelog/migration_11.rst +++ b/doc/build/changelog/migration_11.rst @@ -2129,7 +2129,7 @@ table to an integer "id" column on the other:: pets = relationship( "Pets", primaryjoin=( - "foreign(Pets.person_id)" "==cast(type_coerce(Person.id, Integer), Integer)" + "foreign(Pets.person_id)==cast(type_coerce(Person.id, Integer), Integer)" ), ) diff --git a/doc/build/orm/join_conditions.rst b/doc/build/orm/join_conditions.rst index a4a905c74c..5846b5d206 100644 --- a/doc/build/orm/join_conditions.rst +++ b/doc/build/orm/join_conditions.rst @@ -142,7 +142,7 @@ load those ``Address`` objects which specify a city of "Boston":: name = mapped_column(String) boston_addresses = relationship( "Address", - primaryjoin="and_(User.id==Address.user_id, " "Address.city=='Boston')", + primaryjoin="and_(User.id==Address.user_id, Address.city=='Boston')", ) @@ -297,7 +297,7 @@ a :func:`_orm.relationship`:: network = relationship( "Network", - primaryjoin="IPA.v4address.bool_op('<<')" "(foreign(Network.v4representation))", + primaryjoin="IPA.v4address.bool_op('<<')(foreign(Network.v4representation))", viewonly=True, ) @@ -702,7 +702,7 @@ join condition (requires version 0.9.2 at least to function as is):: d = relationship( "D", - secondary="join(B, D, B.d_id == D.id)." "join(C, C.d_id == D.id)", + secondary="join(B, D, B.d_id == D.id).join(C, C.d_id == D.id)", primaryjoin="and_(A.b_id == B.id, A.id == C.a_id)", secondaryjoin="D.id == B.d_id", uselist=False, diff --git a/lib/sqlalchemy/dialects/oracle/base.py b/lib/sqlalchemy/dialects/oracle/base.py index a6a8138415..a548b34499 100644 --- a/lib/sqlalchemy/dialects/oracle/base.py +++ b/lib/sqlalchemy/dialects/oracle/base.py @@ -594,7 +594,7 @@ RESERVED_WORDS = set( ) NO_ARG_FNS = set( - "UID CURRENT_DATE SYSDATE USER " "CURRENT_TIME CURRENT_TIMESTAMP".split() + "UID CURRENT_DATE SYSDATE USER CURRENT_TIME CURRENT_TIMESTAMP".split() ) diff --git a/lib/sqlalchemy/engine/cursor.py b/lib/sqlalchemy/engine/cursor.py index c9390a9f11..4b18ddb434 100644 --- a/lib/sqlalchemy/engine/cursor.py +++ b/lib/sqlalchemy/engine/cursor.py @@ -1611,11 +1611,11 @@ class CursorResult(Result[_T]): """ if not self.context.compiled: raise exc.InvalidRequestError( - "Statement is not a compiled " "expression construct." + "Statement is not a compiled expression construct." ) elif not self.context.isinsert: raise exc.InvalidRequestError( - "Statement is not an insert() " "expression construct." + "Statement is not an insert() expression construct." ) elif self.context._is_explicit_returning: raise exc.InvalidRequestError( @@ -1682,11 +1682,11 @@ class CursorResult(Result[_T]): """ if not self.context.compiled: raise exc.InvalidRequestError( - "Statement is not a compiled " "expression construct." + "Statement is not a compiled expression construct." ) elif not self.context.isupdate: raise exc.InvalidRequestError( - "Statement is not an update() " "expression construct." + "Statement is not an update() expression construct." ) elif self.context.executemany: return self.context.compiled_parameters @@ -1704,11 +1704,11 @@ class CursorResult(Result[_T]): """ if not self.context.compiled: raise exc.InvalidRequestError( - "Statement is not a compiled " "expression construct." + "Statement is not a compiled expression construct." ) elif not self.context.isinsert: raise exc.InvalidRequestError( - "Statement is not an insert() " "expression construct." + "Statement is not an insert() expression construct." ) elif self.context.executemany: return self.context.compiled_parameters @@ -1921,7 +1921,7 @@ class CursorResult(Result[_T]): if not self.context.compiled: raise exc.InvalidRequestError( - "Statement is not a compiled " "expression construct." + "Statement is not a compiled expression construct." ) elif not self.context.isinsert and not self.context.isupdate: raise exc.InvalidRequestError( @@ -1944,7 +1944,7 @@ class CursorResult(Result[_T]): if not self.context.compiled: raise exc.InvalidRequestError( - "Statement is not a compiled " "expression construct." + "Statement is not a compiled expression construct." ) elif not self.context.isinsert and not self.context.isupdate: raise exc.InvalidRequestError( diff --git a/lib/sqlalchemy/ext/associationproxy.py b/lib/sqlalchemy/ext/associationproxy.py index 86043ba799..80e6fdac98 100644 --- a/lib/sqlalchemy/ext/associationproxy.py +++ b/lib/sqlalchemy/ext/associationproxy.py @@ -1074,7 +1074,7 @@ class AssociationProxyInstance(SQLORMOperations[_T]): and (not self._target_is_object or self._value_is_scalar) ): raise exc.InvalidRequestError( - "'any()' not implemented for scalar " "attributes. Use has()." + "'any()' not implemented for scalar attributes. Use has()." ) return self._criterion_exists( criterion=criterion, is_has=False, **kwargs @@ -1098,7 +1098,7 @@ class AssociationProxyInstance(SQLORMOperations[_T]): or (self._target_is_object and not self._value_is_scalar) ): raise exc.InvalidRequestError( - "'has()' not implemented for collections. " "Use any()." + "'has()' not implemented for collections. Use any()." ) return self._criterion_exists( criterion=criterion, is_has=True, **kwargs diff --git a/lib/sqlalchemy/inspection.py b/lib/sqlalchemy/inspection.py index 4ee48f3851..30d531957f 100644 --- a/lib/sqlalchemy/inspection.py +++ b/lib/sqlalchemy/inspection.py @@ -157,9 +157,7 @@ def _inspects( def decorate(fn_or_cls: _F) -> _F: for type_ in types: if type_ in _registrars: - raise AssertionError( - "Type %s is already " "registered" % type_ - ) + raise AssertionError("Type %s is already registered" % type_) _registrars[type_] = fn_or_cls return fn_or_cls @@ -171,6 +169,6 @@ _TT = TypeVar("_TT", bound="Type[Any]") def _self_inspects(cls: _TT) -> _TT: if cls in _registrars: - raise AssertionError("Type %s is already " "registered" % cls) + raise AssertionError("Type %s is already registered" % cls) _registrars[cls] = True return cls diff --git a/lib/sqlalchemy/orm/interfaces.py b/lib/sqlalchemy/orm/interfaces.py index 68a6f64531..2f090588fe 100644 --- a/lib/sqlalchemy/orm/interfaces.py +++ b/lib/sqlalchemy/orm/interfaces.py @@ -115,7 +115,7 @@ _TLS = TypeVar("_TLS", bound="Type[LoaderStrategy]") class ORMStatementRole(roles.StatementRole): __slots__ = () _role_name = ( - "Executable SQL or text() construct, including ORM " "aware objects" + "Executable SQL or text() construct, including ORM aware objects" ) diff --git a/lib/sqlalchemy/orm/relationships.py b/lib/sqlalchemy/orm/relationships.py index db76bd912f..11ea591127 100644 --- a/lib/sqlalchemy/orm/relationships.py +++ b/lib/sqlalchemy/orm/relationships.py @@ -951,7 +951,7 @@ class RelationshipProperty( """ if self.property.uselist: raise sa_exc.InvalidRequestError( - "'has()' not implemented for collections. " "Use any()." + "'has()' not implemented for collections. Use any()." ) return self._criterion_exists(criterion, **kwargs) diff --git a/lib/sqlalchemy/orm/strategies.py b/lib/sqlalchemy/orm/strategies.py index e38a05f061..20c3b9cc6b 100644 --- a/lib/sqlalchemy/orm/strategies.py +++ b/lib/sqlalchemy/orm/strategies.py @@ -384,7 +384,7 @@ class DeferredColumnLoader(LoaderStrategy): super().__init__(parent, strategy_key) if hasattr(self.parent_property, "composite_class"): raise NotImplementedError( - "Deferred loading for composite " "types not implemented yet" + "Deferred loading for composite types not implemented yet" ) self.raiseload = self.strategy_opts.get("raiseload", False) self.columns = self.parent_property.columns @@ -758,7 +758,7 @@ class LazyLoader( self._equated_columns[c] = self._equated_columns[col] self.logger.info( - "%s will use Session.get() to " "optimize instance loads", self + "%s will use Session.get() to optimize instance loads", self ) def init_class_attribute(self, mapper): diff --git a/lib/sqlalchemy/orm/util.py b/lib/sqlalchemy/orm/util.py index c6102098a6..90508206ee 100644 --- a/lib/sqlalchemy/orm/util.py +++ b/lib/sqlalchemy/orm/util.py @@ -256,9 +256,7 @@ class CascadeOptions(FrozenSet[str]): self.delete_orphan = "delete-orphan" in values if self.delete_orphan and not self.delete: - util.warn( - "The 'delete-orphan' cascade " "option requires 'delete'." - ) + util.warn("The 'delete-orphan' cascade option requires 'delete'.") return self def __repr__(self): diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index 064be4dfdf..ba8e3ea450 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -2532,7 +2532,7 @@ class SQLCompiler(Compiled): def _fallback_column_name(self, column): raise exc.CompileError( - "Cannot compile Column object until " "its 'name' is assigned." + "Cannot compile Column object until its 'name' is assigned." ) def visit_lambda_element(self, element, **kw): @@ -6638,7 +6638,7 @@ class DDLCompiler(Compiled): def _verify_index_table(self, index): if index.table is None: raise exc.CompileError( - "Index '%s' is not associated " "with any table." % index.name + "Index '%s' is not associated with any table." % index.name ) def visit_create_index( diff --git a/lib/sqlalchemy/sql/default_comparator.py b/lib/sqlalchemy/sql/default_comparator.py index 5bf8d582e5..76131bcaa4 100644 --- a/lib/sqlalchemy/sql/default_comparator.py +++ b/lib/sqlalchemy/sql/default_comparator.py @@ -247,7 +247,7 @@ def _unsupported_impl( expr: ColumnElement[Any], op: OperatorType, *arg: Any, **kw: Any ) -> NoReturn: raise NotImplementedError( - "Operator '%s' is not supported on " "this expression" % op.__name__ + "Operator '%s' is not supported on this expression" % op.__name__ ) diff --git a/lib/sqlalchemy/sql/schema.py b/lib/sqlalchemy/sql/schema.py index 96e350447a..2932fffad4 100644 --- a/lib/sqlalchemy/sql/schema.py +++ b/lib/sqlalchemy/sql/schema.py @@ -2063,7 +2063,7 @@ class Column(DialectKWArgs, SchemaItem, ColumnClause[_T]): name = quoted_name(name, quote) elif quote is not None: raise exc.ArgumentError( - "Explicit 'name' is required when " "sending 'quote' argument" + "Explicit 'name' is required when sending 'quote' argument" ) # name = None is expected to be an interim state diff --git a/lib/sqlalchemy/testing/plugin/plugin_base.py b/lib/sqlalchemy/testing/plugin/plugin_base.py index 11eb35cfa9..a642668be9 100644 --- a/lib/sqlalchemy/testing/plugin/plugin_base.py +++ b/lib/sqlalchemy/testing/plugin/plugin_base.py @@ -90,7 +90,7 @@ def setup_options(make_option): action="append", type=str, dest="dburi", - help="Database uri. Multiple OK, " "first one is run by default.", + help="Database uri. Multiple OK, first one is run by default.", ) make_option( "--dbdriver", diff --git a/lib/sqlalchemy/testing/suite/test_rowcount.py b/lib/sqlalchemy/testing/suite/test_rowcount.py index c48ed355c9..a7dbd364f1 100644 --- a/lib/sqlalchemy/testing/suite/test_rowcount.py +++ b/lib/sqlalchemy/testing/suite/test_rowcount.py @@ -204,7 +204,7 @@ class RowCountTest(fixtures.TablesTest): def test_text_rowcount(self, connection): # test issue #3622, make sure eager rowcount is called for text result = connection.execute( - text("update employees set department='Z' " "where department='C'") + text("update employees set department='Z' where department='C'") ) eq_(result.rowcount, 3) diff --git a/lib/sqlalchemy/util/langhelpers.py b/lib/sqlalchemy/util/langhelpers.py index b122a3b35b..396a039771 100644 --- a/lib/sqlalchemy/util/langhelpers.py +++ b/lib/sqlalchemy/util/langhelpers.py @@ -1951,7 +1951,7 @@ NoneType = type(None) def attrsetter(attrname): - code = "def set(obj, value):" " obj.%s = value" % attrname + code = "def set(obj, value): obj.%s = value" % attrname env = locals().copy() exec(code, env) return env["set"] diff --git a/test/dialect/mssql/test_compiler.py b/test/dialect/mssql/test_compiler.py index b5ea40b120..59b13b91e0 100644 --- a/test/dialect/mssql/test_compiler.py +++ b/test/dialect/mssql/test_compiler.py @@ -175,7 +175,7 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): t = table("sometable", column("somecolumn")) self.assert_compile( t.insert(), - "INSERT INTO sometable (somecolumn) VALUES " "(:somecolumn)", + "INSERT INTO sometable (somecolumn) VALUES (:somecolumn)", ) def test_update(self): @@ -862,7 +862,7 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): ) self.assert_compile( tbl.delete().where(tbl.c.id == 1), - "DELETE FROM paj.test WHERE paj.test.id = " ":id_1", + "DELETE FROM paj.test WHERE paj.test.id = :id_1", ) s = select(tbl.c.id).where(tbl.c.id == 1) self.assert_compile( @@ -882,7 +882,7 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): ) self.assert_compile( tbl.delete().where(tbl.c.id == 1), - "DELETE FROM banana.paj.test WHERE " "banana.paj.test.id = :id_1", + "DELETE FROM banana.paj.test WHERE banana.paj.test.id = :id_1", ) s = select(tbl.c.id).where(tbl.c.id == 1) self.assert_compile( @@ -999,7 +999,7 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): ) self.assert_compile( select(func.max(t.c.col1)), - "SELECT max(sometable.col1) AS max_1 FROM " "sometable", + "SELECT max(sometable.col1) AS max_1 FROM sometable", ) def test_function_overrides(self): @@ -1072,7 +1072,7 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): ) d = delete(table1).returning(table1.c.myid, table1.c.name) self.assert_compile( - d, "DELETE FROM mytable OUTPUT deleted.myid, " "deleted.name" + d, "DELETE FROM mytable OUTPUT deleted.myid, deleted.name" ) d = ( delete(table1) @@ -1945,7 +1945,7 @@ class CompileIdentityTest(fixtures.TestBase, AssertsCompiledSQL): ) self.assert_compile( schema.CreateTable(tbl), - "CREATE TABLE test (id INTEGER NOT NULL IDENTITY(3,1)" ")", + "CREATE TABLE test (id INTEGER NOT NULL IDENTITY(3,1))", ) def test_identity_separate_from_primary_key(self): diff --git a/test/dialect/mssql/test_query.py b/test/dialect/mssql/test_query.py index b68b21339e..33f648b82a 100644 --- a/test/dialect/mssql/test_query.py +++ b/test/dialect/mssql/test_query.py @@ -664,7 +664,7 @@ RETURN def test_scalar_strings_named_control(self, scalar_strings, connection): result = ( connection.exec_driver_sql( - "SELECT anon_1.my_string " "FROM scalar_strings() AS anon_1" + "SELECT anon_1.my_string FROM scalar_strings() AS anon_1" ) .scalars() .all() diff --git a/test/dialect/mysql/test_compiler.py b/test/dialect/mysql/test_compiler.py index 05b4b68542..6712300aa4 100644 --- a/test/dialect/mysql/test_compiler.py +++ b/test/dialect/mysql/test_compiler.py @@ -182,7 +182,7 @@ class CompileTest(ReservedWordFixture, fixtures.TestBase, AssertsCompiledSQL): self.assert_compile( schema.CreateIndex(idx), - "CREATE FULLTEXT INDEX test_idx1 " "ON testtbl (data(10))", + "CREATE FULLTEXT INDEX test_idx1 ON testtbl (data(10))", ) def test_create_index_with_text(self): @@ -876,7 +876,7 @@ class SQLTest(fixtures.TestBase, AssertsCompiledSQL): self.assert_compile( schema.CreateIndex(ix1), - "CREATE INDEX %s " "ON %s (%s)" % (exp, tname, cname), + "CREATE INDEX %s ON %s (%s)" % (exp, tname, cname), ) def test_innodb_autoincrement(self): diff --git a/test/dialect/mysql/test_types.py b/test/dialect/mysql/test_types.py index 1d279e720d..c73e82a945 100644 --- a/test/dialect/mysql/test_types.py +++ b/test/dialect/mysql/test_types.py @@ -385,7 +385,7 @@ class TypeCompileTest(fixtures.TestBase, AssertsCompiledSQL): mysql.MSTimeStamp(), DefaultClause( sql.text( - "'1999-09-09 09:09:09' " "ON UPDATE CURRENT_TIMESTAMP" + "'1999-09-09 09:09:09' ON UPDATE CURRENT_TIMESTAMP" ) ), ], @@ -398,7 +398,7 @@ class TypeCompileTest(fixtures.TestBase, AssertsCompiledSQL): mysql.MSTimeStamp, DefaultClause( sql.text( - "'1999-09-09 09:09:09' " "ON UPDATE CURRENT_TIMESTAMP" + "'1999-09-09 09:09:09' ON UPDATE CURRENT_TIMESTAMP" ) ), ], @@ -410,9 +410,7 @@ class TypeCompileTest(fixtures.TestBase, AssertsCompiledSQL): [ mysql.MSTimeStamp(), DefaultClause( - sql.text( - "CURRENT_TIMESTAMP " "ON UPDATE CURRENT_TIMESTAMP" - ) + sql.text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP") ), ], {}, @@ -423,9 +421,7 @@ class TypeCompileTest(fixtures.TestBase, AssertsCompiledSQL): [ mysql.MSTimeStamp, DefaultClause( - sql.text( - "CURRENT_TIMESTAMP " "ON UPDATE CURRENT_TIMESTAMP" - ) + sql.text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP") ), ], {"nullable": False}, @@ -1209,7 +1205,7 @@ class EnumSetTest( t1 = Table("sometable", MetaData(), Column("somecolumn", e1)) self.assert_compile( schema.CreateTable(t1), - "CREATE TABLE sometable (somecolumn " "ENUM('x','y','z'))", + "CREATE TABLE sometable (somecolumn ENUM('x','y','z'))", ) t1 = Table( "sometable", diff --git a/test/dialect/oracle/test_compiler.py b/test/dialect/oracle/test_compiler.py index c7a6858d4c..2165aa0909 100644 --- a/test/dialect/oracle/test_compiler.py +++ b/test/dialect/oracle/test_compiler.py @@ -92,7 +92,7 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): ) self.assert_compile( parent.join(child), - "ed.parent JOIN ed.child ON ed.parent.id = " "ed.child.parent_id", + "ed.parent JOIN ed.child ON ed.parent.id = ed.child.parent_id", ) def test_subquery(self): @@ -1183,7 +1183,7 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): q = select(table1.c.name).where(table1.c.name == "foo") self.assert_compile( q, - "SELECT mytable.name FROM mytable WHERE " "mytable.name = :name_1", + "SELECT mytable.name FROM mytable WHERE mytable.name = :name_1", dialect=oracle.dialect(use_ansi=False), ) @@ -1498,7 +1498,7 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): ) self.assert_compile( schema.CreateTable(tbl2), - "CREATE TABLE testtbl2 (data INTEGER) " "COMPRESS FOR OLTP", + "CREATE TABLE testtbl2 (data INTEGER) COMPRESS FOR OLTP", ) def test_create_index_bitmap_compress(self): diff --git a/test/dialect/oracle/test_dialect.py b/test/dialect/oracle/test_dialect.py index 68ee3f7180..0c4b894f89 100644 --- a/test/dialect/oracle/test_dialect.py +++ b/test/dialect/oracle/test_dialect.py @@ -532,9 +532,7 @@ end; def test_out_params(self, connection): result = connection.execute( - text( - "begin foo(:x_in, :x_out, :y_out, " ":z_out); end;" - ).bindparams( + text("begin foo(:x_in, :x_out, :y_out, :z_out); end;").bindparams( bindparam("x_in", Float), outparam("x_out", Integer), outparam("y_out", Float), @@ -863,7 +861,7 @@ class ExecuteTest(fixtures.TestBase): with testing.db.connect() as conn: eq_( conn.exec_driver_sql( - "/*+ this is a comment */ SELECT 1 FROM " "DUAL" + "/*+ this is a comment */ SELECT 1 FROM DUAL" ).fetchall(), [(1,)], ) diff --git a/test/dialect/postgresql/test_compiler.py b/test/dialect/postgresql/test_compiler.py index 005e60eaa1..f33c251160 100644 --- a/test/dialect/postgresql/test_compiler.py +++ b/test/dialect/postgresql/test_compiler.py @@ -262,7 +262,7 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): ) self.assert_compile( postgresql.CreateEnumType(e2), - "CREATE TYPE someschema.somename AS ENUM " "('x', 'y', 'z')", + "CREATE TYPE someschema.somename AS ENUM ('x', 'y', 'z')", ) self.assert_compile(postgresql.DropEnumType(e1), "DROP TYPE somename") self.assert_compile( @@ -271,7 +271,7 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): t1 = Table("sometable", MetaData(), Column("somecolumn", e1)) self.assert_compile( schema.CreateTable(t1), - "CREATE TABLE sometable (somecolumn " "somename)", + "CREATE TABLE sometable (somecolumn somename)", ) t1 = Table( "sometable", @@ -682,7 +682,7 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): self.assert_compile( schema.CreateIndex(idx), - "CREATE INDEX test_idx1 ON testtbl " "(data text_pattern_ops)", + "CREATE INDEX test_idx1 ON testtbl (data text_pattern_ops)", dialect=postgresql.dialect(), ) self.assert_compile( @@ -725,7 +725,7 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): unique=True, ) ), - "CREATE UNIQUE INDEX test_idx3 ON test_tbl " "(data3)", + "CREATE UNIQUE INDEX test_idx3 ON test_tbl (data3)", ), ( lambda tbl: schema.CreateIndex( @@ -892,17 +892,17 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): self.assert_compile( schema.CreateIndex(idx1), - "CREATE INDEX test_idx1 ON testtbl " "(data)", + "CREATE INDEX test_idx1 ON testtbl (data)", dialect=postgresql.dialect(), ) self.assert_compile( schema.CreateIndex(idx2), - "CREATE INDEX test_idx2 ON testtbl " "USING btree (data)", + "CREATE INDEX test_idx2 ON testtbl USING btree (data)", dialect=postgresql.dialect(), ) self.assert_compile( schema.CreateIndex(idx3), - "CREATE INDEX test_idx3 ON testtbl " "USING hash (data)", + "CREATE INDEX test_idx3 ON testtbl USING hash (data)", dialect=postgresql.dialect(), ) @@ -923,7 +923,7 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): self.assert_compile( schema.CreateIndex(idx1), - "CREATE INDEX test_idx1 ON testtbl " "(data)", + "CREATE INDEX test_idx1 ON testtbl (data)", ) self.assert_compile( schema.CreateIndex(idx2), @@ -946,7 +946,7 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): schema.CreateIndex( Index("test_idx1", tbl.c.data, postgresql_using="GIST") ), - "CREATE INDEX test_idx1 ON testtbl " "USING gist (data)", + "CREATE INDEX test_idx1 ON testtbl USING gist (data)", ) self.assert_compile( @@ -988,7 +988,7 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): self.assert_compile( schema.CreateIndex(idx1), - "CREATE INDEX test_idx1 ON testtbl " "(data)", + "CREATE INDEX test_idx1 ON testtbl (data)", dialect=postgresql.dialect(), ) self.assert_compile( @@ -2083,7 +2083,7 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): # default dialect does not, as DBAPIs may be doing this for us self.assert_compile( t.update().values({t.c.data[2:5]: [2, 3, 4]}), - "UPDATE t SET data[%s:%s]=" "%s", + "UPDATE t SET data[%s:%s]=%s", checkparams={"param_1": [2, 3, 4], "data_2": 5, "data_1": 2}, dialect=PGDialect(paramstyle="format"), ) @@ -2139,7 +2139,7 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): tbl3 = Table("testtbl3", m, Column("id", Integer), schema="testschema") stmt = tbl3.select().with_hint(tbl3, "ONLY", "postgresql") expected = ( - "SELECT testschema.testtbl3.id FROM " "ONLY testschema.testtbl3" + "SELECT testschema.testtbl3.id FROM ONLY testschema.testtbl3" ) self.assert_compile(stmt, expected) @@ -3296,7 +3296,7 @@ class DistinctOnTest(fixtures.MappedTest, AssertsCompiledSQL): sess = Session() self.assert_compile( sess.query(self.table).distinct(), - "SELECT DISTINCT t.id AS t_id, t.a AS t_a, " "t.b AS t_b FROM t", + "SELECT DISTINCT t.id AS t_id, t.a AS t_a, t.b AS t_b FROM t", ) def test_query_on_columns(self): diff --git a/test/dialect/postgresql/test_dialect.py b/test/dialect/postgresql/test_dialect.py index 919842a49c..32a5a84ac8 100644 --- a/test/dialect/postgresql/test_dialect.py +++ b/test/dialect/postgresql/test_dialect.py @@ -721,7 +721,7 @@ class MultiHostConnectTest(fixtures.TestBase): "postgresql+psycopg2://USER:PASS@/DB" "?host=hostA,hostC&port=111,222,333", ), - ("postgresql+psycopg2://USER:PASS@/DB" "?host=hostA&port=111,222",), + ("postgresql+psycopg2://USER:PASS@/DB?host=hostA&port=111,222",), ( "postgresql+asyncpg://USER:PASS@/DB" "?host=hostA,hostB,hostC&port=111,333", diff --git a/test/dialect/postgresql/test_query.py b/test/dialect/postgresql/test_query.py index 9822b3e60b..a737381760 100644 --- a/test/dialect/postgresql/test_query.py +++ b/test/dialect/postgresql/test_query.py @@ -977,7 +977,7 @@ class MatchTest(fixtures.TablesTest, AssertsCompiledSQL): if self._strs_render_bind_casts(connection): self.assert_compile( matchtable.c.title.match("somstr"), - "matchtable.title @@ " "plainto_tsquery(%(title_1)s::VARCHAR)", + "matchtable.title @@ plainto_tsquery(%(title_1)s::VARCHAR)", ) else: self.assert_compile( diff --git a/test/dialect/test_sqlite.py b/test/dialect/test_sqlite.py index d5ff0fc19d..245b762cf3 100644 --- a/test/dialect/test_sqlite.py +++ b/test/dialect/test_sqlite.py @@ -84,12 +84,12 @@ class TestTypes(fixtures.TestBase, AssertsExecutionResults): ) metadata.create_all(connection) for stmt in [ - "INSERT INTO bool_table (id, boo) " "VALUES (1, 'false');", - "INSERT INTO bool_table (id, boo) " "VALUES (2, 'true');", - "INSERT INTO bool_table (id, boo) " "VALUES (3, '1');", - "INSERT INTO bool_table (id, boo) " "VALUES (4, '0');", - "INSERT INTO bool_table (id, boo) " "VALUES (5, 1);", - "INSERT INTO bool_table (id, boo) " "VALUES (6, 0);", + "INSERT INTO bool_table (id, boo) VALUES (1, 'false');", + "INSERT INTO bool_table (id, boo) VALUES (2, 'true');", + "INSERT INTO bool_table (id, boo) VALUES (3, '1');", + "INSERT INTO bool_table (id, boo) VALUES (4, '0');", + "INSERT INTO bool_table (id, boo) VALUES (5, 1);", + "INSERT INTO bool_table (id, boo) VALUES (6, 0);", ]: connection.exec_driver_sql(stmt) @@ -653,7 +653,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 @@ -741,7 +741,7 @@ class DialectTest( ), ), ( - "sqlite:///file:path/to/database?" "mode=ro&uri=true", + "sqlite:///file:path/to/database?mode=ro&uri=true", ( ["file:path/to/database?mode=ro"], {"uri": True, "check_same_thread": False}, @@ -1155,7 +1155,7 @@ class OnConflictDDLTest(fixtures.TestBase, AssertsCompiledSQL): self.assert_compile( schema.CreateColumn(c), - "test INTEGER NOT NULL " "ON CONFLICT FAIL", + "test INTEGER NOT NULL ON CONFLICT FAIL", dialect=sqlite.dialect(), ) @@ -1194,7 +1194,7 @@ class OnConflictDDLTest(fixtures.TestBase, AssertsCompiledSQL): self.assert_compile( CreateTable(t), - "CREATE TABLE n (x VARCHAR(30), " "UNIQUE (x) ON CONFLICT FAIL)", + "CREATE TABLE n (x VARCHAR(30), UNIQUE (x) ON CONFLICT FAIL)", dialect=sqlite.dialect(), ) diff --git a/test/engine/test_parseconnect.py b/test/engine/test_parseconnect.py index 34dc1d7aa8..16b129fd8a 100644 --- a/test/engine/test_parseconnect.py +++ b/test/engine/test_parseconnect.py @@ -373,7 +373,7 @@ class URLTest(fixtures.TestBase): ( "foo1=bar1&foo2=bar21&foo2=bar22&foo3=bar31", "foo2=bar23&foo3=bar32&foo3=bar33", - "foo1=bar1&foo2=bar23&" "foo3=bar32&foo3=bar33", + "foo1=bar1&foo2=bar23&foo3=bar32&foo3=bar33", False, ), ) @@ -573,7 +573,7 @@ class CreateEngineTest(fixtures.TestBase): e = engine_from_config(config, module=dbapi, _initialize=False) assert e.pool._recycle == 50 assert e.url == url.make_url( - "postgresql+psycopg2://scott:tiger@somehost/test?foo" "z=somevalue" + "postgresql+psycopg2://scott:tiger@somehost/test?fooz=somevalue" ) assert e.echo is True diff --git a/test/engine/test_transaction.py b/test/engine/test_transaction.py index 4ae87c4ad1..a70e8e05d0 100644 --- a/test/engine/test_transaction.py +++ b/test/engine/test_transaction.py @@ -345,9 +345,7 @@ class TransactionTest(fixtures.TablesTest): assert not trans.is_active eq_( - connection.exec_driver_sql( - "select count(*) from " "users" - ).scalar(), + connection.exec_driver_sql("select count(*) from users").scalar(), 2, ) connection.rollback() diff --git a/test/orm/declarative/test_basic.py b/test/orm/declarative/test_basic.py index 37a1b643c1..1f31544e06 100644 --- a/test/orm/declarative/test_basic.py +++ b/test/orm/declarative/test_basic.py @@ -1387,7 +1387,7 @@ class DeclarativeMultiBaseTest( assert_raises_message( sa.exc.ArgumentError, - "Can't add additional column 'foo' when " "specifying __table__", + "Can't add additional column 'foo' when specifying __table__", go, ) @@ -1825,7 +1825,7 @@ class DeclarativeMultiBaseTest( assert_raises_message( exc.InvalidRequestError, - "'addresses' is not an instance of " "ColumnProperty", + "'addresses' is not an instance of ColumnProperty", configure_mappers, ) @@ -1954,7 +1954,7 @@ class DeclarativeMultiBaseTest( assert_raises_message( AttributeError, - "does not have a mapped column named " "'__table__'", + "does not have a mapped column named '__table__'", configure_mappers, ) @@ -2508,7 +2508,7 @@ class DeclarativeMultiBaseTest( def test_oops(self): with testing.expect_warnings( - "Ignoring declarative-like tuple value of " "attribute 'name'" + "Ignoring declarative-like tuple value of attribute 'name'" ): class User(Base, ComparableEntity): diff --git a/test/orm/declarative/test_mixin.py b/test/orm/declarative/test_mixin.py index 32f737484e..2520eb846d 100644 --- a/test/orm/declarative/test_mixin.py +++ b/test/orm/declarative/test_mixin.py @@ -1322,7 +1322,7 @@ class DeclarativeMixinTest(DeclarativeTestBase): assert_raises_message( sa.exc.ArgumentError, - "Can't add additional column 'tada' when " "specifying __table__", + "Can't add additional column 'tada' when specifying __table__", go, ) diff --git a/test/orm/dml/test_bulk.py b/test/orm/dml/test_bulk.py index baa6c20f83..62b435e9cb 100644 --- a/test/orm/dml/test_bulk.py +++ b/test/orm/dml/test_bulk.py @@ -238,7 +238,7 @@ class BulkInsertUpdateTest(BulkTest, _fixtures.FixtureTest): asserter.assert_( CompiledSQL( - "UPDATE users SET name=:name WHERE " "users.id = :users_id", + "UPDATE users SET name=:name WHERE users.id = :users_id", [ {"users_id": 1, "name": "u1new"}, {"users_id": 2, "name": "u2"}, diff --git a/test/orm/inheritance/test_basic.py b/test/orm/inheritance/test_basic.py index a76f563f81..9028fd25a4 100644 --- a/test/orm/inheritance/test_basic.py +++ b/test/orm/inheritance/test_basic.py @@ -1684,7 +1684,7 @@ class PassiveDeletesTest(fixtures.MappedTest): s.flush() asserter.assert_( RegexSQL( - "SELECT .* " "FROM c WHERE :param_1 = c.bid", [{"param_1": 3}] + "SELECT .* FROM c WHERE :param_1 = c.bid", [{"param_1": 3}] ), CompiledSQL("DELETE FROM c WHERE c.cid = :cid", [{"cid": 1}]), CompiledSQL("DELETE FROM b WHERE b.id = :id", [{"id": 3}]), @@ -3012,7 +3012,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 @@ -3744,7 +3744,7 @@ class NoPolyIdentInMiddleTest(fixtures.MappedTest): __mapper_args__ = {"polymorphic_identity": "b"} with expect_warnings( - r"Mapper\[C\(a\)\] does not indicate a " "'polymorphic_identity'," + r"Mapper\[C\(a\)\] does not indicate a 'polymorphic_identity'," ): class C(A): diff --git a/test/orm/test_bind.py b/test/orm/test_bind.py index 976df514f3..abd008cadf 100644 --- a/test/orm/test_bind.py +++ b/test/orm/test_bind.py @@ -464,7 +464,7 @@ class BindIntegrationTest(_fixtures.FixtureTest): engine = {"e1": e1, "e2": e2, "e3": e3}[expected_engine_name] with mock.patch( - "sqlalchemy.orm.context." "ORMCompileState.orm_setup_cursor_result" + "sqlalchemy.orm.context.ORMCompileState.orm_setup_cursor_result" ), mock.patch( "sqlalchemy.orm.context.ORMCompileState.orm_execute_statement" ), mock.patch( @@ -529,7 +529,7 @@ class BindIntegrationTest(_fixtures.FixtureTest): assert_raises_message( sa.exc.InvalidRequestError, - "Session already has a Connection " "associated", + "Session already has a Connection associated", transaction._connection_for_bind, testing.db.connect(), None, diff --git a/test/orm/test_core_compilation.py b/test/orm/test_core_compilation.py index dd0d597b22..915c9747f8 100644 --- a/test/orm/test_core_compilation.py +++ b/test/orm/test_core_compilation.py @@ -555,7 +555,7 @@ class DMLTest(QueryTest, AssertsCompiledSQL): self.assert_compile( stmt, - "DELETE FROM users AS users_1 " "WHERE users_1.name = :name_1", + "DELETE FROM users AS users_1 WHERE users_1.name = :name_1", ) @testing.variation("stmt_type", ["core", "orm"]) diff --git a/test/orm/test_cycles.py b/test/orm/test_cycles.py index cffde9bdab..fb37185f53 100644 --- a/test/orm/test_cycles.py +++ b/test/orm/test_cycles.py @@ -1188,7 +1188,7 @@ class OneToManyManyToOneTest(fixtures.MappedTest): ], ), CompiledSQL( - "DELETE FROM person " "WHERE person.id = :id", + "DELETE FROM person WHERE person.id = :id", lambda ctx: [{"id": p.id}], ), CompiledSQL( diff --git a/test/orm/test_deprecations.py b/test/orm/test_deprecations.py index f943d8dfe4..bf545d6ad9 100644 --- a/test/orm/test_deprecations.py +++ b/test/orm/test_deprecations.py @@ -1995,7 +1995,7 @@ class MixedEntitiesTest(QueryTest, AssertsCompiledSQL): @testing.fails_on("mssql", "FIXME: unknown") @testing.fails_on( - "oracle", "Oracle doesn't support boolean expressions as " "columns" + "oracle", "Oracle doesn't support boolean expressions as columns" ) @testing.fails_on( "postgresql+pg8000", diff --git a/test/orm/test_events.py b/test/orm/test_events.py index 02e00fe947..3af6aad86a 100644 --- a/test/orm/test_events.py +++ b/test/orm/test_events.py @@ -1671,7 +1671,7 @@ class DeclarativeEventListenTest( class DeferredMapperEventsTest(RemoveORMEventsGlobally, _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_mapper.py b/test/orm/test_mapper.py index f93c18d216..64d0ac9abd 100644 --- a/test/orm/test_mapper.py +++ b/test/orm/test_mapper.py @@ -3483,7 +3483,7 @@ class ConfigureOrNotConfigureTest(_fixtures.FixtureTest, AssertsCompiledSQL): self.assert_compile( stmt, - "SELECT users.id, " "users.name " "FROM users", + "SELECT users.id, users.name FROM users", ) is_true(um.configured) diff --git a/test/orm/test_options.py b/test/orm/test_options.py index 9362d52470..db9b51607c 100644 --- a/test/orm/test_options.py +++ b/test/orm/test_options.py @@ -981,7 +981,7 @@ class OptionsNoPropTest(_fixtures.FixtureTest): if first_element else (Load(Item).joinedload(Keyword),) ), - "expected ORM mapped attribute for loader " "strategy argument", + "expected ORM mapped attribute for loader strategy argument", ) @testing.combinations( diff --git a/test/orm/test_query.py b/test/orm/test_query.py index a06406c115..ea108c345b 100644 --- a/test/orm/test_query.py +++ b/test/orm/test_query.py @@ -3563,7 +3563,7 @@ class FilterTest(QueryTest, AssertsCompiledSQL): self.assert_compile( q1, - "SELECT users.id AS foo FROM users " "WHERE users.name = :name_1", + "SELECT users.id AS foo FROM users WHERE users.name = :name_1", ) def test_empty_filters(self): @@ -4348,7 +4348,7 @@ class ExistsTest(QueryTest, AssertsCompiledSQL): q1 = sess.query(User) self.assert_compile( sess.query(q1.exists()), - "SELECT EXISTS (" "SELECT 1 FROM users" ") AS anon_1", + "SELECT EXISTS (SELECT 1 FROM users) AS anon_1", ) q2 = sess.query(User).filter(User.name == "fred") @@ -4366,7 +4366,7 @@ class ExistsTest(QueryTest, AssertsCompiledSQL): q1 = sess.query(User.id) self.assert_compile( sess.query(q1.exists()), - "SELECT EXISTS (" "SELECT 1 FROM users" ") AS anon_1", + "SELECT EXISTS (SELECT 1 FROM users) AS anon_1", ) def test_exists_labeled_col_expression(self): @@ -4376,7 +4376,7 @@ class ExistsTest(QueryTest, AssertsCompiledSQL): q1 = sess.query(User.id.label("foo")) self.assert_compile( sess.query(q1.exists()), - "SELECT EXISTS (" "SELECT 1 FROM users" ") AS anon_1", + "SELECT EXISTS (SELECT 1 FROM users) AS anon_1", ) def test_exists_arbitrary_col_expression(self): @@ -4386,7 +4386,7 @@ class ExistsTest(QueryTest, AssertsCompiledSQL): q1 = sess.query(func.foo(User.id)) self.assert_compile( sess.query(q1.exists()), - "SELECT EXISTS (" "SELECT 1 FROM users" ") AS anon_1", + "SELECT EXISTS (SELECT 1 FROM users) AS anon_1", ) def test_exists_col_warning(self): @@ -5178,7 +5178,7 @@ class PrefixSuffixWithTest(QueryTest, AssertsCompiledSQL): User = self.classes.User sess = fixture_session() query = sess.query(User.name).prefix_with("PREFIX_1") - expected = "SELECT PREFIX_1 " "users.name AS users_name FROM users" + expected = "SELECT PREFIX_1 users.name AS users_name FROM users" self.assert_compile(query, expected, dialect=default.DefaultDialect()) def test_one_suffix(self): @@ -5194,7 +5194,7 @@ class PrefixSuffixWithTest(QueryTest, AssertsCompiledSQL): sess = fixture_session() query = sess.query(User.name).prefix_with("PREFIX_1", "PREFIX_2") expected = ( - "SELECT PREFIX_1 PREFIX_2 " "users.name AS users_name FROM users" + "SELECT PREFIX_1 PREFIX_2 users.name AS users_name FROM users" ) self.assert_compile(query, expected, dialect=default.DefaultDialect()) diff --git a/test/orm/test_selectin_relations.py b/test/orm/test_selectin_relations.py index c9907c7651..93b3d8710c 100644 --- a/test/orm/test_selectin_relations.py +++ b/test/orm/test_selectin_relations.py @@ -3429,7 +3429,7 @@ class M2OWDegradeTest( testing.db, q.all, CompiledSQL( - "SELECT a.id AS a_id, a.q AS a_q " "FROM a ORDER BY a.id", [{}] + "SELECT a.id AS a_id, a.q AS a_q FROM a ORDER BY a.id", [{}] ), # in the very unlikely case that the the FK col on parent is # deferred, we degrade to the JOIN version so that we don't need to diff --git a/test/orm/test_unitofwork.py b/test/orm/test_unitofwork.py index 3b3175e10e..7b29b4362a 100644 --- a/test/orm/test_unitofwork.py +++ b/test/orm/test_unitofwork.py @@ -2299,7 +2299,7 @@ class ManyToOneTest(_fixtures.FixtureTest): testing.db, session.flush, CompiledSQL( - "INSERT INTO users (name) " "VALUES (:name)", + "INSERT INTO users (name) VALUES (:name)", {"name": "imnewlyadded"}, ), AllOf( @@ -2616,7 +2616,7 @@ class ManyToManyTest(_fixtures.FixtureTest): {"description": "item4updated", "items_id": objects[4].id}, ), CompiledSQL( - "INSERT INTO keywords (name) " "VALUES (:name)", + "INSERT INTO keywords (name) VALUES (:name)", {"name": "yellow"}, ), CompiledSQL( @@ -3416,7 +3416,7 @@ class InheritingRowSwitchTest(fixtures.MappedTest): # sync operation during _save_obj().update, this is safe to remove # again. CompiledSQL( - "UPDATE child SET pid=:pid " "WHERE child.cid = :child_cid", + "UPDATE child SET pid=:pid WHERE child.cid = :child_cid", {"pid": 1, "child_cid": 1}, ), ) diff --git a/test/orm/test_unitofworkv2.py b/test/orm/test_unitofworkv2.py index e01220d115..90ea0eaa03 100644 --- a/test/orm/test_unitofworkv2.py +++ b/test/orm/test_unitofworkv2.py @@ -3045,7 +3045,7 @@ class EagerDefaultsTest(fixtures.MappedTest): testing.db, s.flush, CompiledSQL( - "INSERT INTO test2 (id, foo, bar) " "VALUES (:id, :foo, :bar)", + "INSERT INTO test2 (id, foo, bar) VALUES (:id, :foo, :bar)", [{"id": 1, "foo": None, "bar": 2}], ), ) diff --git a/test/perf/orm2010.py b/test/perf/orm2010.py index c069430fb1..520944c9f0 100644 --- a/test/perf/orm2010.py +++ b/test/perf/orm2010.py @@ -149,14 +149,12 @@ def run_with_profile(runsnake=False, dump=False): print("Total cpu seconds: %.2f" % stats.total_tt) print( "Total execute calls: %d" - % counts_by_methname[ - "" - ] + % counts_by_methname[""] ) print( "Total executemany calls: %d" % counts_by_methname.get( - "", 0 + "", 0 ) ) diff --git a/test/requirements.py b/test/requirements.py index 8b137fe467..a692cd3fee 100644 --- a/test/requirements.py +++ b/test/requirements.py @@ -999,7 +999,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( @@ -1027,7 +1027,7 @@ class DefaultRequirements(SuiteRequirements): @property def emulated_lastrowid_even_with_sequences(self): - """ "target dialect retrieves cursor.lastrowid or an equivalent + """target dialect retrieves cursor.lastrowid or an equivalent after an insert() construct executes, even if the table has a Sequence on it. """ @@ -1040,7 +1040,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 5756bb6927..9d9f69bdb9 100644 --- a/test/sql/test_compiler.py +++ b/test/sql/test_compiler.py @@ -1544,7 +1544,7 @@ class SelectTest(fixtures.TestBase, AssertsCompiledSQL): ) self.assert_compile( select(select(table1.c.name).label("foo")), - "SELECT (SELECT mytable.name FROM mytable) " "AS foo", + "SELECT (SELECT mytable.name FROM mytable) AS foo", ) # scalar selects should not have any attributes on their 'c' or @@ -2694,7 +2694,7 @@ class SelectTest(fixtures.TestBase, AssertsCompiledSQL): self.assert_compile( s3, - "SELECT NULL AS anon_1, NULL AS anon__1 " "UNION " + "SELECT NULL AS anon_1, NULL AS anon__1 UNION " # without the feature tested in test_deduping_hash_algo we'd get # "SELECT true AS anon_2, true AS anon__1", "SELECT true AS anon_2, true AS anon__2", @@ -3775,7 +3775,7 @@ class BindParameterTest(AssertsCompiledSQL, fixtures.TestBase): ) assert_raises_message( exc.CompileError, - "conflicts with unique bind parameter " "of the same name", + "conflicts with unique bind parameter of the same name", str, s, ) @@ -3789,7 +3789,7 @@ class BindParameterTest(AssertsCompiledSQL, fixtures.TestBase): ) assert_raises_message( exc.CompileError, - "conflicts with unique bind parameter " "of the same name", + "conflicts with unique bind parameter of the same name", str, s, ) @@ -4434,7 +4434,7 @@ class BindParameterTest(AssertsCompiledSQL, fixtures.TestBase): ) self.assert_compile( expr, - "(mytable.myid, mytable.name) IN " "(__[POSTCOMPILE_param_1])", + "(mytable.myid, mytable.name) IN (__[POSTCOMPILE_param_1])", checkparams={"param_1": [(1, "foo"), (5, "bar")]}, check_post_param={"param_1": [(1, "foo"), (5, "bar")]}, check_literal_execute={}, @@ -4469,7 +4469,7 @@ class BindParameterTest(AssertsCompiledSQL, fixtures.TestBase): dialect.tuple_in_values = True self.assert_compile( tuple_(table1.c.myid, table1.c.name).in_([(1, "foo"), (5, "bar")]), - "(mytable.myid, mytable.name) IN " "(__[POSTCOMPILE_param_1])", + "(mytable.myid, mytable.name) IN (__[POSTCOMPILE_param_1])", dialect=dialect, checkparams={"param_1": [(1, "foo"), (5, "bar")]}, check_post_param={"param_1": [(1, "foo"), (5, "bar")]}, @@ -4816,7 +4816,7 @@ class BindParameterTest(AssertsCompiledSQL, fixtures.TestBase): select(table1.c.myid).where( table1.c.myid == bindparam("foo", 5, literal_execute=True) ), - "SELECT mytable.myid FROM mytable " "WHERE mytable.myid = 5", + "SELECT mytable.myid FROM mytable WHERE mytable.myid = 5", literal_binds=True, ) @@ -4843,7 +4843,7 @@ class BindParameterTest(AssertsCompiledSQL, fixtures.TestBase): select(table1.c.myid).where( table1.c.myid == bindparam("foo", 5, literal_execute=True) ), - "SELECT mytable.myid FROM mytable " "WHERE mytable.myid = 5", + "SELECT mytable.myid FROM mytable WHERE mytable.myid = 5", render_postcompile=True, ) @@ -6136,7 +6136,7 @@ class StringifySpecialTest(fixtures.TestBase): eq_ignore_whitespace( str(schema.AddConstraint(cons)), - "ALTER TABLE testtbl ADD EXCLUDE USING gist " "(room WITH =)", + "ALTER TABLE testtbl ADD EXCLUDE USING gist (room WITH =)", ) def test_try_cast(self): @@ -7337,7 +7337,7 @@ class CorrelateTest(fixtures.TestBase, AssertsCompiledSQL): s = select(t1.c.a) s2 = select(t1).where(t1.c.a == s.scalar_subquery()) self.assert_compile( - s2, "SELECT t1.a FROM t1 WHERE t1.a = " "(SELECT t1.a FROM t1)" + s2, "SELECT t1.a FROM t1 WHERE t1.a = (SELECT t1.a FROM t1)" ) def test_correlate_semiauto_where_singlefrom(self): diff --git a/test/sql/test_constraints.py b/test/sql/test_constraints.py index 54fcba576c..93c385ba4d 100644 --- a/test/sql/test_constraints.py +++ b/test/sql/test_constraints.py @@ -286,7 +286,7 @@ class ConstraintGenTest(fixtures.TestBase, AssertsExecutionResults): if auto: fk_assertions.append( CompiledSQL( - "ALTER TABLE a ADD " "FOREIGN KEY(bid) REFERENCES b (id)" + "ALTER TABLE a ADD FOREIGN KEY(bid) REFERENCES b (id)" ) ) assertions.append(AllOf(*fk_assertions)) @@ -409,10 +409,10 @@ class ConstraintGenTest(fixtures.TestBase, AssertsExecutionResults): ), AllOf( CompiledSQL( - "ALTER TABLE b ADD " "FOREIGN KEY(aid) REFERENCES a (id)" + "ALTER TABLE b ADD FOREIGN KEY(aid) REFERENCES a (id)" ), CompiledSQL( - "ALTER TABLE a ADD " "FOREIGN KEY(bid) REFERENCES b (id)" + "ALTER TABLE a ADD FOREIGN KEY(bid) REFERENCES b (id)" ), ), ] @@ -720,10 +720,10 @@ class ConstraintGenTest(fixtures.TestBase, AssertsExecutionResults): RegexSQL("^CREATE TABLE events"), AllOf( CompiledSQL( - "CREATE UNIQUE INDEX ix_events_name ON events " "(name)" + "CREATE UNIQUE INDEX ix_events_name ON events (name)" ), CompiledSQL( - "CREATE INDEX ix_events_location ON events " "(location)" + "CREATE INDEX ix_events_location ON events (location)" ), CompiledSQL( "CREATE UNIQUE INDEX sport_announcer ON events " @@ -817,7 +817,7 @@ class ConstraintCompilationTest(fixtures.TestBase, AssertsCompiledSQL): self.assert_compile( schema.CreateIndex(ix1), - "CREATE INDEX %s " "ON %s (%s)" % (exp, tname, cname), + "CREATE INDEX %s ON %s (%s)" % (exp, tname, cname), dialect=dialect, ) @@ -1237,7 +1237,7 @@ class ConstraintCompilationTest(fixtures.TestBase, AssertsCompiledSQL): # is disabled self.assert_compile( schema.CreateTable(t), - "CREATE TABLE tbl (" "a INTEGER, " "b INTEGER" ")", + "CREATE TABLE tbl (a INTEGER, b INTEGER)", ) def test_render_drop_constraint(self): diff --git a/test/sql/test_cte.py b/test/sql/test_cte.py index 0b665b84da..ef7eac51e3 100644 --- a/test/sql/test_cte.py +++ b/test/sql/test_cte.py @@ -518,7 +518,7 @@ class CTETest(fixtures.TestBase, AssertsCompiledSQL): else: assert_raises_message( CompileError, - "Multiple, unrelated CTEs found " "with the same name: 'cte1'", + "Multiple, unrelated CTEs found with the same name: 'cte1'", s.compile, ) diff --git a/test/sql/test_deprecations.py b/test/sql/test_deprecations.py index dbb5644cd1..96b636bd05 100644 --- a/test/sql/test_deprecations.py +++ b/test/sql/test_deprecations.py @@ -326,7 +326,7 @@ class SelectableTest(fixtures.TestBase, AssertsCompiledSQL): sel = select(basefrom.c.a) with testing.expect_deprecated( - r"The Selectable.replace_selectable\(\) " "method is deprecated" + r"The Selectable.replace_selectable\(\) method is deprecated" ): replaced = sel.replace_selectable( basefrom, basefrom.join(joinfrom, basefrom.c.a == joinfrom.c.a) diff --git a/test/sql/test_external_traversal.py b/test/sql/test_external_traversal.py index 0204d6e6fc..d044d8b57f 100644 --- a/test/sql/test_external_traversal.py +++ b/test/sql/test_external_traversal.py @@ -2185,7 +2185,7 @@ class ClauseAdapterTest(fixtures.TestBase, AssertsCompiledSQL): def test_table_to_alias_9(self): s = select(literal_column("*")).select_from(t1).alias("foo") self.assert_compile( - s.select(), "SELECT foo.* FROM (SELECT * FROM table1) " "AS foo" + s.select(), "SELECT foo.* FROM (SELECT * FROM table1) AS foo" ) def test_table_to_alias_10(self): @@ -2194,13 +2194,13 @@ class ClauseAdapterTest(fixtures.TestBase, AssertsCompiledSQL): vis = sql_util.ClauseAdapter(t1alias) self.assert_compile( vis.traverse(s.select()), - "SELECT foo.* FROM (SELECT * FROM table1 " "AS t1alias) AS foo", + "SELECT foo.* FROM (SELECT * FROM table1 AS t1alias) AS foo", ) def test_table_to_alias_11(self): s = select(literal_column("*")).select_from(t1).alias("foo") self.assert_compile( - s.select(), "SELECT foo.* FROM (SELECT * FROM table1) " "AS foo" + s.select(), "SELECT foo.* FROM (SELECT * FROM table1) AS foo" ) def test_table_to_alias_12(self): @@ -2209,7 +2209,7 @@ class ClauseAdapterTest(fixtures.TestBase, AssertsCompiledSQL): ff = vis.traverse(func.count(t1.c.col1).label("foo")) self.assert_compile( select(ff), - "SELECT count(t1alias.col1) AS foo FROM " "table1 AS t1alias", + "SELECT count(t1alias.col1) AS foo FROM table1 AS t1alias", ) assert list(_from_objects(ff)) == [t1alias] @@ -2700,7 +2700,7 @@ class SpliceJoinsTest(fixtures.TestBase, AssertsCompiledSQL): ) self.assert_compile( sql_util.splice_joins(table1, j2), - "table1 JOIN table4 AS table4_1 ON " "table1.col3 = table4_1.col3", + "table1 JOIN table4 AS table4_1 ON table1.col3 = table4_1.col3", ) self.assert_compile( sql_util.splice_joins(sql_util.splice_joins(table1, j1), j2), @@ -2726,23 +2726,23 @@ class SelectTest(fixtures.TestBase, AssertsCompiledSQL): def test_columns(self): s = t1.select() self.assert_compile( - s, "SELECT table1.col1, table1.col2, " "table1.col3 FROM table1" + s, "SELECT table1.col1, table1.col2, table1.col3 FROM table1" ) select_copy = s.add_columns(column("yyy")) self.assert_compile( select_copy, - "SELECT table1.col1, table1.col2, " "table1.col3, yyy FROM table1", + "SELECT table1.col1, table1.col2, table1.col3, yyy FROM table1", ) is_not(s.selected_columns, select_copy.selected_columns) is_not(s._raw_columns, select_copy._raw_columns) self.assert_compile( - s, "SELECT table1.col1, table1.col2, " "table1.col3 FROM table1" + s, "SELECT table1.col1, table1.col2, table1.col3 FROM table1" ) def test_froms(self): s = t1.select() self.assert_compile( - s, "SELECT table1.col1, table1.col2, " "table1.col3 FROM table1" + s, "SELECT table1.col1, table1.col2, table1.col3 FROM table1" ) select_copy = s.select_from(t2) self.assert_compile( @@ -2752,13 +2752,13 @@ class SelectTest(fixtures.TestBase, AssertsCompiledSQL): ) self.assert_compile( - s, "SELECT table1.col1, table1.col2, " "table1.col3 FROM table1" + s, "SELECT table1.col1, table1.col2, table1.col3 FROM table1" ) def test_prefixes(self): s = t1.select() self.assert_compile( - s, "SELECT table1.col1, table1.col2, " "table1.col3 FROM table1" + s, "SELECT table1.col1, table1.col2, table1.col3 FROM table1" ) select_copy = s.prefix_with("FOOBER") self.assert_compile( @@ -2767,7 +2767,7 @@ class SelectTest(fixtures.TestBase, AssertsCompiledSQL): "table1.col3 FROM table1", ) self.assert_compile( - s, "SELECT table1.col1, table1.col2, " "table1.col3 FROM table1" + s, "SELECT table1.col1, table1.col2, table1.col3 FROM table1" ) def test_execution_options(self): diff --git a/test/sql/test_insert.py b/test/sql/test_insert.py index ddfb9aea20..a5cfad5b69 100644 --- a/test/sql/test_insert.py +++ b/test/sql/test_insert.py @@ -1120,7 +1120,7 @@ class InsertTest(_InsertTestBase, fixtures.TablesTest, AssertsCompiledSQL): Column("q", Integer), ) with expect_warnings( - "Column 't.x' is marked as a member.*" "may not store NULL.$" + "Column 't.x' is marked as a member.*may not store NULL.$" ): self.assert_compile( t.insert(), "INSERT INTO t (q) VALUES (:q)", params={"q": 5} @@ -1136,7 +1136,7 @@ class InsertTest(_InsertTestBase, fixtures.TablesTest, AssertsCompiledSQL): d = postgresql.dialect() d.implicit_returning = True with expect_warnings( - "Column 't.x' is marked as a member.*" "may not store NULL.$" + "Column 't.x' is marked as a member.*may not store NULL.$" ): self.assert_compile( t.insert(), @@ -1156,7 +1156,7 @@ class InsertTest(_InsertTestBase, fixtures.TablesTest, AssertsCompiledSQL): d.implicit_returning = False with expect_warnings( - "Column 't.x' is marked as a member.*" "may not store NULL.$" + "Column 't.x' is marked as a member.*may not store NULL.$" ): self.assert_compile( t.insert(), @@ -1172,7 +1172,7 @@ class InsertTest(_InsertTestBase, fixtures.TablesTest, AssertsCompiledSQL): Column("notpk", String(10), nullable=True), ) with expect_warnings( - "Column 't.id' is marked as a member.*" "may not store NULL.$" + "Column 't.id' is marked as a member.*may not store NULL.$" ): self.assert_compile( t.insert(), @@ -1755,7 +1755,7 @@ class MultirowTest(_InsertTestBase, fixtures.TablesTest, AssertsCompiledSQL): self.assert_compile( stmt, - "INSERT INTO sometable (id, data) VALUES " "(foobar(), ?)", + "INSERT INTO sometable (id, data) VALUES (foobar(), ?)", checkparams={"data": "foo"}, params={"data": "foo"}, dialect=dialect, diff --git a/test/sql/test_lambdas.py b/test/sql/test_lambdas.py index 627310d8f1..17991ea2e3 100644 --- a/test/sql/test_lambdas.py +++ b/test/sql/test_lambdas.py @@ -221,7 +221,7 @@ class LambdaElementTest( self.assert_compile( go("u1"), - "SELECT users.id FROM users " "WHERE users.name = 'u1'", + "SELECT users.id FROM users WHERE users.name = 'u1'", literal_binds=True, ) diff --git a/test/sql/test_metadata.py b/test/sql/test_metadata.py index 3592bc6f00..8b43b0f98a 100644 --- a/test/sql/test_metadata.py +++ b/test/sql/test_metadata.py @@ -2882,7 +2882,7 @@ class UseExistingTest(testing.AssertsCompiledSQL, fixtures.TablesTest): assert_raises_message( exc.InvalidRequestError, - "Table 'users' is already defined for this " "MetaData instance.", + "Table 'users' is already defined for this MetaData instance.", go, ) @@ -5665,7 +5665,7 @@ class NamingConventionTest(fixtures.TestBase, AssertsCompiledSQL): dialect.max_identifier_length = 15 self.assert_compile( schema.CreateIndex(ix), - "CREATE INDEX ix_user_2de9 ON " '"user" (data, "Data2", "Data3")', + 'CREATE INDEX ix_user_2de9 ON "user" (data, "Data2", "Data3")', dialect=dialect, ) @@ -5949,7 +5949,7 @@ class NamingConventionTest(fixtures.TestBase, AssertsCompiledSQL): # no issue with native boolean self.assert_compile( schema.CreateTable(u1), - 'CREATE TABLE "user" (' "x BOOLEAN" ")", + """CREATE TABLE "user" (x BOOLEAN)""", dialect="postgresql", ) diff --git a/test/sql/test_operators.py b/test/sql/test_operators.py index c0b5cb47d6..9c87b35577 100644 --- a/test/sql/test_operators.py +++ b/test/sql/test_operators.py @@ -419,7 +419,7 @@ class MultiElementExprTest(fixtures.TestBase, testing.AssertsCompiledSQL): ), ( lambda p, q: (1 - p) * (2 - q) * (3 - p) * (4 - q), - "(:p_1 - t.p) * (:q_1 - t.q) * " "(:p_2 - t.p) * (:q_2 - t.q)", + "(:p_1 - t.p) * (:q_1 - t.q) * (:p_2 - t.p) * (:q_2 - t.q)", ), ( lambda p, q: ( @@ -3227,7 +3227,7 @@ class RegexpTestStrCompiler(fixtures.TestBase, testing.AssertsCompiledSQL): self.table.c.myid.match("foo"), self.table.c.myid.regexp_match("xx"), ), - "mytable.myid MATCH :myid_1 AND " "mytable.myid :myid_2", + "mytable.myid MATCH :myid_1 AND mytable.myid :myid_2", ) self.assert_compile( and_( diff --git a/test/sql/test_quote.py b/test/sql/test_quote.py index 51382b19b4..f3bc8e4948 100644 --- a/test/sql/test_quote.py +++ b/test/sql/test_quote.py @@ -821,7 +821,7 @@ class QuoteTest(fixtures.TestBase, AssertsCompiledSQL): # what if table/schema *are* quoted? self.assert_compile( t1.select().set_label_style(LABEL_STYLE_TABLENAME_PLUS_COL), - "SELECT " "Foo.T1.Col1 AS Foo_T1_Col1 " "FROM " "Foo.T1", + "SELECT Foo.T1.Col1 AS Foo_T1_Col1 FROM Foo.T1", ) def test_quote_flag_propagate_check_constraint(self): @@ -830,7 +830,7 @@ class QuoteTest(fixtures.TestBase, AssertsCompiledSQL): CheckConstraint(t.c.x > 5) self.assert_compile( schema.CreateTable(t), - "CREATE TABLE t (" '"x" INTEGER, ' 'CHECK ("x" > 5)' ")", + 'CREATE TABLE t ("x" INTEGER, CHECK ("x" > 5))', ) def test_quote_flag_propagate_index(self): diff --git a/test/sql/test_resultset.py b/test/sql/test_resultset.py index be1f57121b..8651207a91 100644 --- a/test/sql/test_resultset.py +++ b/test/sql/test_resultset.py @@ -490,7 +490,7 @@ class CursorResultTest(fixtures.TablesTest): if use_pickle: with expect_raises_message( exc.NoSuchColumnError, - "Row was unpickled; lookup by ColumnElement is " "unsupported", + "Row was unpickled; lookup by ColumnElement is unsupported", ): result[0]._mapping[users.c.user_id] else: @@ -499,7 +499,7 @@ class CursorResultTest(fixtures.TablesTest): if use_pickle: with expect_raises_message( exc.NoSuchColumnError, - "Row was unpickled; lookup by ColumnElement is " "unsupported", + "Row was unpickled; lookup by ColumnElement is unsupported", ): result[0]._mapping[users.c.user_name] else: diff --git a/test/sql/test_text.py b/test/sql/test_text.py index 301ad9ffdf..941a02d9e7 100644 --- a/test/sql/test_text.py +++ b/test/sql/test_text.py @@ -470,7 +470,7 @@ class BindParamTest(fixtures.TestBase, AssertsCompiledSQL): r"SELECT * FROM pg_attribute WHERE " r"attrelid = :tab\:\:regclass" ), - "SELECT * FROM pg_attribute WHERE " "attrelid = %(tab)s::regclass", + "SELECT * FROM pg_attribute WHERE attrelid = %(tab)s::regclass", params={"tab": None}, dialect="postgresql", ) @@ -483,7 +483,7 @@ class BindParamTest(fixtures.TestBase, AssertsCompiledSQL): r"SELECT * FROM pg_attribute WHERE " r"attrelid = foo::regclass" ), - "SELECT * FROM pg_attribute WHERE " "attrelid = foo::regclass", + "SELECT * FROM pg_attribute WHERE attrelid = foo::regclass", params={}, dialect="postgresql", ) diff --git a/test/sql/test_types.py b/test/sql/test_types.py index 76249f5617..898d6fa0a8 100644 --- a/test/sql/test_types.py +++ b/test/sql/test_types.py @@ -2303,7 +2303,7 @@ class EnumTest(AssertsCompiledSQL, fixtures.TablesTest): assert_raises( (exc.DBAPIError,), connection.exec_driver_sql, - "insert into my_table " "(data) values('four')", + "insert into my_table (data) values('four')", ) trans.rollback()