Reformat with black 26.1.0

This commit is contained in:
Claude 2026-01-21 15:23:44 +00:00
commit cb33bec699
No known key found for this signature in database
12 changed files with 48 additions and 114 deletions

View file

@ -42,7 +42,6 @@ from .utils import (
TypeTracker,
)
CONTEXT_SETTINGS = dict(help_option_names=["-h", "--help"])
@ -2919,8 +2918,7 @@ def _analyze(db, tables, columns, save, common_limit=10, no_most=False, no_least
)
details = (
(
textwrap.dedent(
"""
textwrap.dedent("""
{table}.{column}: ({i}/{total})
Total rows: {total_rows}
@ -2928,8 +2926,7 @@ def _analyze(db, tables, columns, save, common_limit=10, no_most=False, no_least
Blank rows: {num_blank}
Distinct values: {num_distinct}{most_common_rendered}{least_common_rendered}
"""
)
""")
.strip()
.format(
i=i + 1,
@ -2976,8 +2973,7 @@ def uninstall(packages, yes):
def _generate_convert_help():
help = textwrap.dedent(
"""
help = textwrap.dedent("""
Convert columns using Python code you supply. For example:
\b
@ -2990,8 +2986,7 @@ def _generate_convert_help():
Use "-" for CODE to read Python code from standard input.
The following common operations are available as recipe functions:
"""
).strip()
""").strip()
recipe_names = [
n
for n in dir(recipes)
@ -3005,15 +3000,13 @@ def _generate_convert_help():
name, str(inspect.signature(fn)), textwrap.dedent(fn.__doc__.rstrip())
)
help += "\n\n"
help += textwrap.dedent(
"""
help += textwrap.dedent("""
You can use these recipes like so:
\b
sqlite-utils convert my.db mytable mycolumn \\
'r.jsonsplit(value, delimiter=":")'
"""
).strip()
""").strip()
return help

View file

@ -2348,12 +2348,10 @@ class Table(Queryable):
"{}_{}".format(index_name, suffix) if suffix else index_name
)
sql = (
textwrap.dedent(
"""
textwrap.dedent("""
CREATE {unique}INDEX {if_not_exists}{index_name}
ON {table_name} ({columns});
"""
)
""")
.strip()
.format(
index_name=quote_identifier(created_index_name),
@ -2548,8 +2546,7 @@ class Table(Queryable):
See :ref:`python_api_cached_table_counts` for details.
"""
sql = (
textwrap.dedent(
"""
textwrap.dedent("""
{create_counts_table}
CREATE TRIGGER IF NOT EXISTS {trigger_insert} AFTER INSERT ON {table}
BEGIN
@ -2574,8 +2571,7 @@ class Table(Queryable):
);
END;
INSERT OR REPLACE INTO _counts VALUES ({table_quoted}, (select count(*) from {table}));
"""
)
""")
.strip()
.format(
create_counts_table=_COUNTS_TABLE_CREATE_SQL.format(
@ -2627,14 +2623,12 @@ class Table(Queryable):
:param replace: Should any existing FTS index for this table be replaced by the new one?
"""
create_fts_sql = (
textwrap.dedent(
"""
textwrap.dedent("""
CREATE VIRTUAL TABLE {table_fts} USING {fts_version} (
{columns},{tokenize}
content={table}
)
"""
)
""")
.strip()
.format(
table=quote_identifier(self.name),
@ -2672,8 +2666,7 @@ class Table(Queryable):
table = quote_identifier(self.name)
table_fts = quote_identifier(self.name + "_fts")
triggers = (
textwrap.dedent(
"""
textwrap.dedent("""
CREATE TRIGGER {table_ai} AFTER INSERT ON {table} BEGIN
INSERT INTO {table_fts} (rowid, {columns}) VALUES (new.rowid, {new_cols});
END;
@ -2684,8 +2677,7 @@ class Table(Queryable):
INSERT INTO {table_fts} ({table_fts}, rowid, {columns}) VALUES('delete', old.rowid, {old_cols});
INSERT INTO {table_fts} (rowid, {columns}) VALUES (new.rowid, {new_cols});
END;
"""
)
""")
.strip()
.format(
table=table,
@ -2710,12 +2702,10 @@ class Table(Queryable):
"""
columns_quoted = ", ".join(quote_identifier(c) for c in columns)
sql = (
textwrap.dedent(
"""
textwrap.dedent("""
INSERT INTO {table_fts} (rowid, {columns})
SELECT rowid, {columns} FROM {table};
"""
)
""")
.strip()
.format(
table=quote_identifier(self.name),
@ -2732,17 +2722,11 @@ class Table(Queryable):
if fts_table:
self.db[fts_table].drop()
# Now delete the triggers that related to that table
sql = (
textwrap.dedent(
"""
sql = textwrap.dedent("""
SELECT name FROM sqlite_master
WHERE type = 'trigger'
AND (sql LIKE '% INSERT INTO [{}]%' OR sql LIKE '% INSERT INTO "{}"%')
"""
)
.strip()
.format(fts_table, fts_table)
)
""").strip().format(fts_table, fts_table)
trigger_names = []
for row in self.db.execute(sql).fetchall():
trigger_names.append(row[0])
@ -2768,8 +2752,7 @@ class Table(Queryable):
def detect_fts(self) -> Optional[str]:
"Detect if table has a corresponding FTS virtual table and return it"
sql = textwrap.dedent(
"""
sql = textwrap.dedent("""
SELECT name FROM sqlite_master
WHERE rootpage = 0
AND (
@ -2780,8 +2763,7 @@ class Table(Queryable):
AND sql LIKE '%VIRTUAL TABLE%USING FTS%'
)
)
"""
).strip()
""").strip()
args = {
"like": '%VIRTUAL TABLE%USING FTS%content="{}"%'.format(self.name),
"like2": '%VIRTUAL TABLE%USING FTS%content="{}"%'.format(self.name),
@ -2797,13 +2779,9 @@ class Table(Queryable):
"Run the ``optimize`` operation against the associated full-text search index table."
fts_table = self.detect_fts()
if fts_table is not None:
self.db.execute(
"""
self.db.execute("""
INSERT INTO {table} ({table}) VALUES ("optimize");
""".strip().format(
table=quote_identifier(fts_table)
)
)
""".strip().format(table=quote_identifier(fts_table)))
return self
def search_sql(
@ -2841,8 +2819,7 @@ class Table(Queryable):
)
fts_table_quoted = quote_identifier(fts_table)
virtual_table_using = self.db.table(fts_table).virtual_table_using
sql = textwrap.dedent(
"""
sql = textwrap.dedent("""
with {original} as (
select
rowid,
@ -2859,8 +2836,7 @@ class Table(Queryable):
order by
{order_by}
{limit_offset}
"""
).strip()
""").strip()
if virtual_table_using == "FTS5":
rank_implementation = "{}.rank".format(fts_table_quoted)
else: