mirror of
https://github.com/PyMySQL/mysqlclient.git
synced 2025-08-14 10:02:22 +08:00
Run pyupgrade --py38-plus (#590)
This commit is contained in:
@ -299,7 +299,7 @@ class Connection(_mysql.connection):
|
||||
super().set_character_set(charset)
|
||||
self.encoding = _charset_to_encoding.get(charset, charset)
|
||||
if collation:
|
||||
self.query("SET NAMES %s COLLATE %s" % (charset, collation))
|
||||
self.query(f"SET NAMES {charset} COLLATE {collation}")
|
||||
self.store_result()
|
||||
|
||||
def set_sql_mode(self, sql_mode):
|
||||
|
@ -29,7 +29,7 @@ if __name__ == "__main__":
|
||||
data[value].add(name)
|
||||
for value, names in sorted(data.items()):
|
||||
for name in sorted(names):
|
||||
print("{} = {}".format(name, value))
|
||||
print(f"{name} = {value}")
|
||||
if error_last is not None:
|
||||
print("ERROR_LAST = %s" % error_last)
|
||||
|
||||
|
@ -30,7 +30,7 @@ if __name__ == "__main__":
|
||||
data[value].add(name)
|
||||
for value, names in sorted(data.items()):
|
||||
for name in sorted(names):
|
||||
print("{} = {}".format(name, value))
|
||||
print(f"{name} = {value}")
|
||||
if error_last is not None:
|
||||
print("ERROR_LAST = %s" % error_last)
|
||||
|
||||
|
@ -22,7 +22,7 @@ def enabled(options, option):
|
||||
elif s in ("no", "false", "0", "n"):
|
||||
return False
|
||||
else:
|
||||
raise ValueError("Unknown value {} for option {}".format(value, option))
|
||||
raise ValueError(f"Unknown value {value} for option {option}")
|
||||
|
||||
|
||||
def create_release_file(metadata):
|
||||
|
@ -35,13 +35,13 @@ class DatabaseTest(unittest.TestCase):
|
||||
|
||||
del self.cursor
|
||||
orphans = gc.collect()
|
||||
self.failIf(
|
||||
self.assertFalse(
|
||||
orphans, "%d orphaned objects found after deleting cursor" % orphans
|
||||
)
|
||||
|
||||
del self.connection
|
||||
orphans = gc.collect()
|
||||
self.failIf(
|
||||
self.assertFalse(
|
||||
orphans, "%d orphaned objects found after deleting connection" % orphans
|
||||
)
|
||||
|
||||
@ -82,7 +82,7 @@ class DatabaseTest(unittest.TestCase):
|
||||
def check_data_integrity(self, columndefs, generator):
|
||||
# insert
|
||||
self.create_table(columndefs)
|
||||
insert_statement = "INSERT INTO %s VALUES (%s)" % (
|
||||
insert_statement = "INSERT INTO {} VALUES ({})".format(
|
||||
self.table,
|
||||
",".join(["%s"] * len(columndefs)),
|
||||
)
|
||||
@ -113,7 +113,7 @@ class DatabaseTest(unittest.TestCase):
|
||||
return ("%i" % (row % 10)) * 255
|
||||
|
||||
self.create_table(columndefs)
|
||||
insert_statement = "INSERT INTO %s VALUES (%s)" % (
|
||||
insert_statement = "INSERT INTO {} VALUES ({})".format(
|
||||
self.table,
|
||||
",".join(["%s"] * len(columndefs)),
|
||||
)
|
||||
@ -131,11 +131,11 @@ class DatabaseTest(unittest.TestCase):
|
||||
self.assertEqual(res[i][j], generator(i, j))
|
||||
delete_statement = "delete from %s where col1=%%s" % self.table
|
||||
self.cursor.execute(delete_statement, (0,))
|
||||
self.cursor.execute("select col1 from %s where col1=%s" % (self.table, 0))
|
||||
self.cursor.execute(f"select col1 from {self.table} where col1=%s", (0,))
|
||||
res = self.cursor.fetchall()
|
||||
self.assertFalse(res, "DELETE didn't work")
|
||||
self.connection.rollback()
|
||||
self.cursor.execute("select col1 from %s where col1=%s" % (self.table, 0))
|
||||
self.cursor.execute(f"select col1 from {self.table} where col1=%s", (0,))
|
||||
res = self.cursor.fetchall()
|
||||
self.assertTrue(len(res) == 1, "ROLLBACK didn't work")
|
||||
self.cursor.execute("drop table %s" % (self.table))
|
||||
@ -150,7 +150,7 @@ class DatabaseTest(unittest.TestCase):
|
||||
return ("%i" % (row % 10)) * ((255 - self.rows // 2) + row)
|
||||
|
||||
self.create_table(columndefs)
|
||||
insert_statement = "INSERT INTO %s VALUES (%s)" % (
|
||||
insert_statement = "INSERT INTO {} VALUES ({})".format(
|
||||
self.table,
|
||||
",".join(["%s"] * len(columndefs)),
|
||||
)
|
||||
|
@ -525,8 +525,7 @@ class DatabaseAPI20Test(unittest.TestCase):
|
||||
tests.
|
||||
"""
|
||||
populate = [
|
||||
"insert into {}booze values ('{}')".format(self.table_prefix, s)
|
||||
for s in self.samples
|
||||
f"insert into {self.table_prefix}booze values ('{s}')" for s in self.samples
|
||||
]
|
||||
return populate
|
||||
|
||||
|
@ -18,7 +18,7 @@ def teardown_function(function):
|
||||
c = _conns[0]
|
||||
cur = c.cursor()
|
||||
for t in _tables:
|
||||
cur.execute("DROP TABLE {}".format(t))
|
||||
cur.execute(f"DROP TABLE {t}")
|
||||
cur.close()
|
||||
del _tables[:]
|
||||
|
||||
|
@ -18,7 +18,7 @@ def teardown_function(function):
|
||||
c = _conns[0]
|
||||
cur = c.cursor()
|
||||
for t in _tables:
|
||||
cur.execute("DROP TABLE {}".format(t))
|
||||
cur.execute(f"DROP TABLE {t}")
|
||||
cur.close()
|
||||
del _tables[:]
|
||||
|
||||
|
Reference in New Issue
Block a user