Skip to content

Commit 1f906e6

Browse files
authored
Run pyupgrade --py38-plus (#590)
1 parent 418b68d commit 1f906e6

File tree

8 files changed

+14
-15
lines changed

8 files changed

+14
-15
lines changed

MySQLdb/connections.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ def set_character_set(self, charset, collation=None):
299299
super().set_character_set(charset)
300300
self.encoding = _charset_to_encoding.get(charset, charset)
301301
if collation:
302-
self.query("SET NAMES %s COLLATE %s" % (charset, collation))
302+
self.query(f"SET NAMES {charset} COLLATE {collation}")
303303
self.store_result()
304304

305305
def set_sql_mode(self, sql_mode):

MySQLdb/constants/CR.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
data[value].add(name)
3030
for value, names in sorted(data.items()):
3131
for name in sorted(names):
32-
print("{} = {}".format(name, value))
32+
print(f"{name} = {value}")
3333
if error_last is not None:
3434
print("ERROR_LAST = %s" % error_last)
3535

MySQLdb/constants/ER.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
data[value].add(name)
3131
for value, names in sorted(data.items()):
3232
for name in sorted(names):
33-
print("{} = {}".format(name, value))
33+
print(f"{name} = {value}")
3434
if error_last is not None:
3535
print("ERROR_LAST = %s" % error_last)
3636

setup_common.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def enabled(options, option):
2222
elif s in ("no", "false", "0", "n"):
2323
return False
2424
else:
25-
raise ValueError("Unknown value {} for option {}".format(value, option))
25+
raise ValueError(f"Unknown value {value} for option {option}")
2626

2727

2828
def create_release_file(metadata):

tests/capabilities.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ def tearDown(self):
3535

3636
del self.cursor
3737
orphans = gc.collect()
38-
self.failIf(
38+
self.assertFalse(
3939
orphans, "%d orphaned objects found after deleting cursor" % orphans
4040
)
4141

4242
del self.connection
4343
orphans = gc.collect()
44-
self.failIf(
44+
self.assertFalse(
4545
orphans, "%d orphaned objects found after deleting connection" % orphans
4646
)
4747

@@ -82,7 +82,7 @@ def create_table(self, columndefs):
8282
def check_data_integrity(self, columndefs, generator):
8383
# insert
8484
self.create_table(columndefs)
85-
insert_statement = "INSERT INTO %s VALUES (%s)" % (
85+
insert_statement = "INSERT INTO {} VALUES ({})".format(
8686
self.table,
8787
",".join(["%s"] * len(columndefs)),
8888
)
@@ -113,7 +113,7 @@ def generator(row, col):
113113
return ("%i" % (row % 10)) * 255
114114

115115
self.create_table(columndefs)
116-
insert_statement = "INSERT INTO %s VALUES (%s)" % (
116+
insert_statement = "INSERT INTO {} VALUES ({})".format(
117117
self.table,
118118
",".join(["%s"] * len(columndefs)),
119119
)
@@ -131,11 +131,11 @@ def generator(row, col):
131131
self.assertEqual(res[i][j], generator(i, j))
132132
delete_statement = "delete from %s where col1=%%s" % self.table
133133
self.cursor.execute(delete_statement, (0,))
134-
self.cursor.execute("select col1 from %s where col1=%s" % (self.table, 0))
134+
self.cursor.execute(f"select col1 from {self.table} where col1=%s", (0,))
135135
res = self.cursor.fetchall()
136136
self.assertFalse(res, "DELETE didn't work")
137137
self.connection.rollback()
138-
self.cursor.execute("select col1 from %s where col1=%s" % (self.table, 0))
138+
self.cursor.execute(f"select col1 from {self.table} where col1=%s", (0,))
139139
res = self.cursor.fetchall()
140140
self.assertTrue(len(res) == 1, "ROLLBACK didn't work")
141141
self.cursor.execute("drop table %s" % (self.table))
@@ -150,7 +150,7 @@ def generator(row, col):
150150
return ("%i" % (row % 10)) * ((255 - self.rows // 2) + row)
151151

152152
self.create_table(columndefs)
153-
insert_statement = "INSERT INTO %s VALUES (%s)" % (
153+
insert_statement = "INSERT INTO {} VALUES ({})".format(
154154
self.table,
155155
",".join(["%s"] * len(columndefs)),
156156
)

tests/dbapi20.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -525,8 +525,7 @@ def _populate(self):
525525
tests.
526526
"""
527527
populate = [
528-
"insert into {}booze values ('{}')".format(self.table_prefix, s)
529-
for s in self.samples
528+
f"insert into {self.table_prefix}booze values ('{s}')" for s in self.samples
530529
]
531530
return populate
532531

tests/test_cursor.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def teardown_function(function):
1818
c = _conns[0]
1919
cur = c.cursor()
2020
for t in _tables:
21-
cur.execute("DROP TABLE {}".format(t))
21+
cur.execute(f"DROP TABLE {t}")
2222
cur.close()
2323
del _tables[:]
2424

tests/test_errors.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def teardown_function(function):
1818
c = _conns[0]
1919
cur = c.cursor()
2020
for t in _tables:
21-
cur.execute("DROP TABLE {}".format(t))
21+
cur.execute(f"DROP TABLE {t}")
2222
cur.close()
2323
del _tables[:]
2424

0 commit comments

Comments
 (0)