Skip to content

Commit

Permalink
fully update to flake8 6.1.0
Browse files Browse the repository at this point in the history
I updated flake8 in pre-commit a few days ago but forgot to do it in
tox.

this flake seems to be picking inside of f-strings, which black does
not fix, so fix these manually.

Change-Id: I9a641a99e280fbba9d893a6f1f051b5039d5d4eb
  • Loading branch information
zzzeek committed Nov 24, 2023
1 parent e7c0ed0 commit 7bc33ca
Show file tree
Hide file tree
Showing 15 changed files with 44 additions and 35 deletions.
4 changes: 2 additions & 2 deletions lib/sqlalchemy/dialects/mssql/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1551,8 +1551,8 @@ def process(value):

def process(value):
return f"""'{
value.replace("-", "").replace("'", "''")
}'"""
value.replace("-", "").replace("'", "''")
}'"""

return process

Expand Down
8 changes: 4 additions & 4 deletions lib/sqlalchemy/dialects/postgresql/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1706,10 +1706,10 @@ def render_bind_cast(self, type_, dbapi_type, sqltext):
# see #9511
dbapi_type = sqltypes.STRINGTYPE
return f"""{sqltext}::{
self.dialect.type_compiler_instance.process(
dbapi_type, identifier_preparer=self.preparer
)
}"""
self.dialect.type_compiler_instance.process(
dbapi_type, identifier_preparer=self.preparer
)
}"""

def visit_array(self, element, **kw):
return "ARRAY[%s]" % self.visit_clauselist(element, **kw)
Expand Down
4 changes: 2 additions & 2 deletions lib/sqlalchemy/dialects/postgresql/pg8000.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,8 +584,8 @@ def _set_client_encoding(self, dbapi_connection, client_encoding):
cursor = dbapi_connection.cursor()
cursor.execute(
f"""SET CLIENT_ENCODING TO '{
client_encoding.replace("'", "''")
}'"""
client_encoding.replace("'", "''")
}'"""
)
cursor.execute("COMMIT")
cursor.close()
Expand Down
19 changes: 10 additions & 9 deletions lib/sqlalchemy/engine/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2067,15 +2067,16 @@ def _exec_insertmany_context(
if self._echo:
self._log_info(sql_util._long_statement(sub_stmt))

imv_stats = f""" {
imv_batch.batchnum}/{imv_batch.total_batches} ({
'ordered'
if imv_batch.rows_sorted else 'unordered'
}{
'; batch not supported'
if imv_batch.is_downgraded
else ''
})"""
imv_stats = f""" {imv_batch.batchnum}/{
imv_batch.total_batches
} ({
'ordered'
if imv_batch.rows_sorted else 'unordered'
}{
'; batch not supported'
if imv_batch.is_downgraded
else ''
})"""

if imv_batch.batchnum == 1:
stats += imv_stats
Expand Down
2 changes: 1 addition & 1 deletion lib/sqlalchemy/engine/reflection.py
Original file line number Diff line number Diff line change
Expand Up @@ -1843,7 +1843,7 @@ def _reflect_indexes(
if not expressions:
util.warn(
f"Skipping {flavor} {name!r} because key "
f"{index+1} reflected as None but no "
f"{index + 1} reflected as None but no "
"'expressions' were returned"
)
break
Expand Down
8 changes: 5 additions & 3 deletions lib/sqlalchemy/orm/loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,11 @@ def go(obj):

raise sa_exc.InvalidRequestError(
"Can't apply uniqueness to row tuple containing value of "
f"""type {datatype!r}; {'the values returned appear to be'
if uncertain else 'this datatype produces'} """
"non-hashable values"
f"""type {datatype!r}; {
'the values returned appear to be'
if uncertain
else 'this datatype produces'
} non-hashable values"""
)

return go
Expand Down
3 changes: 2 additions & 1 deletion lib/sqlalchemy/orm/persistence.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,8 @@ def _collect_update_commands(
f"No primary key value supplied for column(s) "
f"""{
', '.join(
str(c) for c in pks if pk_params[c._label] is None)
str(c) for c in pks if pk_params[c._label] is None
)
}; """
"per-row ORM Bulk UPDATE by Primary Key requires that "
"records contain primary key values",
Expand Down
7 changes: 4 additions & 3 deletions lib/sqlalchemy/orm/strategy_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -1611,9 +1611,10 @@ def _raise_for_no_match(self, parent_loader, mapper_entities):
f"Mapped class {path[0]} does not apply to any of the "
f"root entities in this query, e.g. "
f"""{
", ".join(str(x.entity_zero)
for x in mapper_entities if x.entity_zero
)}. Please """
", ".join(
str(x.entity_zero)
for x in mapper_entities if x.entity_zero
)}. Please """
"specify the full path "
"from one of the root entities to the target "
"attribute. "
Expand Down
2 changes: 1 addition & 1 deletion test/dialect/mssql/test_reflection.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ def test_global_temp_different_collation(
):
"""test #8035"""

tname = f"##foo{random.randint(1,1000000)}"
tname = f"##foo{random.randint(1, 1000000)}"

with temp_db_alt_collation_fixture.connect() as conn:
conn.exec_driver_sql(f"CREATE TABLE {tname} (id int primary key)")
Expand Down
2 changes: 1 addition & 1 deletion test/dialect/oracle/test_reflection.py
Original file line number Diff line number Diff line change
Expand Up @@ -1227,7 +1227,7 @@ def _run_test(self, metadata, connection, specs, attributes):
for attr in attributes:
r_attr = getattr(reflected_type, attr)
e_attr = getattr(expected_spec, attr)
col = f"c{i+1}"
col = f"c{i + 1}"
eq_(
r_attr,
e_attr,
Expand Down
6 changes: 4 additions & 2 deletions test/engine/test_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,8 +460,10 @@ def _checkin_event_fixture(self, _is_asyncio=False, _has_terminate=False):
@event.listens_for(p, "reset")
def reset(conn, rec, state):
canary.append(
f"""reset_{'rollback_ok'
if state.asyncio_safe else 'no_rollback'}"""
f"""reset_{
'rollback_ok'
if state.asyncio_safe else 'no_rollback'
}"""
)

@event.listens_for(p, "checkin")
Expand Down
6 changes: 4 additions & 2 deletions test/orm/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -697,8 +697,10 @@ def process_result_value(self, value, dialect):
sa_exc.InvalidRequestError,
r"Can't apply uniqueness to row tuple "
r"containing value of type MyType\(\); "
rf"""{'the values returned appear to be'
if uncertain else 'this datatype produces'} """
rf"""{
'the values returned appear to be'
if uncertain else 'this datatype produces'
} """
r"non-hashable values",
):
result = s.execute(q).unique().all()
Expand Down
2 changes: 1 addition & 1 deletion test/perf/many_table_reflection.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def generate_table(meta: sa.MetaData, min_cols, max_cols, dialect_name):
args.append(sa.ForeignKey(f"table_{target}.table_{target}_col_1"))
cols.append(
sa.Column(
f"table_{table_num}_col_{i+1}",
f"table_{table_num}_col_{i + 1}",
*args,
primary_key=i == 0,
comment=f"primary key of table_{table_num}"
Expand Down
4 changes: 2 additions & 2 deletions test/sql/test_insert_exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -2060,7 +2060,7 @@ def test_sentinel_on_non_autoinc_primary_key(
collection_cls(r),
collection_cls(
[
(uuids[i], f"d{i+1}", "some_server_default")
(uuids[i], f"d{i + 1}", "some_server_default")
for i in range(5)
]
),
Expand All @@ -2072,7 +2072,7 @@ def test_sentinel_on_non_autoinc_primary_key(
collection_cls(
[
(
f"d{i+1}",
f"d{i + 1}",
"some_server_default",
)
for i in range(5)
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ setenv=
[testenv:lint]
basepython = python3
deps=
flake8==6.0.0
flake8==6.1.0
flake8-import-order
flake8-builtins
flake8-future-annotations>=0.0.5
Expand Down

0 comments on commit 7bc33ca

Please sign in to comment.