From 1db721f09e5620f6d4ef31eaf14fcc7a090e916d Mon Sep 17 00:00:00 2001 From: Ryan Forsyth Date: Fri, 1 Apr 2022 15:42:38 -0700 Subject: [PATCH] Update black to fix click ImportError --- .pre-commit-config.yaml | 2 +- conda/dev.yml | 2 +- zstash/create.py | 6 +++--- zstash/extract.py | 6 +++--- zstash/hpss_utils.py | 4 ++-- zstash/ls.py | 8 ++++---- zstash/update.py | 4 ++-- zstash/utils.py | 6 +++--- 8 files changed, 19 insertions(+), 19 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8b62d814..9eff9939 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,7 +12,7 @@ repos: exclude: conda/meta.yaml - repo: https://github.com/psf/black - rev: 20.8b1 + rev: 22.3.0 hooks: - id: black diff --git a/conda/dev.yml b/conda/dev.yml index a5e74ec0..dddfcbb2 100644 --- a/conda/dev.yml +++ b/conda/dev.yml @@ -13,7 +13,7 @@ dependencies: # Developer Tools # ================= # If versions are updated, also update 'rev' in `.pre-commit.config.yaml` - - black=20.8b1 + - black=22.3.0 - flake8=3.8.4 - flake8-isort=4.0.0 - mypy=0.790 diff --git a/zstash/create.py b/zstash/create.py index 425e416d..de93fbd4 100644 --- a/zstash/create.py +++ b/zstash/create.py @@ -186,7 +186,7 @@ def create_database(cache: str, args: argparse.Namespace) -> List[str]: # Create 'config' table cur.execute( - u""" + """ create table config ( arg text primary key, value text @@ -197,7 +197,7 @@ def create_database(cache: str, args: argparse.Namespace) -> List[str]: # Create 'files' table cur.execute( - u""" + """ create table files ( id integer primary key, name text, @@ -226,7 +226,7 @@ def create_database(cache: str, args: argparse.Namespace) -> List[str]: # This creates a new row in the 'config' table. # Insert attr for column 1 ('arg') # Insert value for column 2 ('text') - cur.execute(u"insert into config values (?,?)", (attr, value)) + cur.execute("insert into config values (?,?)", (attr, value)) con.commit() files: List[str] = get_files_to_archive(cache, args.exclude) diff --git a/zstash/extract.py b/zstash/extract.py index bc44ac77..be6f55a1 100644 --- a/zstash/extract.py +++ b/zstash/extract.py @@ -212,7 +212,7 @@ def extract_database( if args.files != ["*"]: raise ValueError("If --tars is used, should not be listed.") tar_names_initial: List[Tuple[str]] = cur.execute( - u"select distinct tar from files" + "select distinct tar from files" ).fetchall() tar_names: List[str] = sorted([x for (x,) in tar_names_initial]) # Remove `.tar` with `[:-4]` for `parse_tars_option` to work properly @@ -221,7 +221,7 @@ def extract_database( ) for tar in tar_list: cur.execute( - u"select * from files where tar GLOB ?", + "select * from files where tar GLOB ?", (tar + ".tar",), ) matches_ = matches_ + cur.fetchall() @@ -229,7 +229,7 @@ def extract_database( # Find matching files for args_file in args.files: cur.execute( - u"select * from files where name GLOB ? or tar GLOB ?", + "select * from files where name GLOB ? or tar GLOB ?", (args_file, args_file), ) match: List[TupleFilesRow] = cur.fetchall() diff --git a/zstash/hpss_utils.py b/zstash/hpss_utils.py index 9aa6b0fa..2e1ed419 100644 --- a/zstash/hpss_utils.py +++ b/zstash/hpss_utils.py @@ -147,7 +147,7 @@ def add_files( if not tars_table_exists(cur): # Need to create tars table create_tars_table(cur, con) - cur.execute(u"insert into tars values (NULL,?,?,?)", tar_tuple) + cur.execute("insert into tars values (NULL,?,?,?)", tar_tuple) con.commit() # Transfer tar to HPSS @@ -160,7 +160,7 @@ def add_files( # Update database with files that have been archived # Add a row to the "files" table, # the last 6 columns matching the values of `archived` - cur.executemany(u"insert into files values (NULL,?,?,?,?,?,?)", archived) + cur.executemany("insert into files values (NULL,?,?,?,?,?,?)", archived) con.commit() # Open new tar next time diff --git a/zstash/ls.py b/zstash/ls.py index 6cd92b5d..b71e39cd 100644 --- a/zstash/ls.py +++ b/zstash/ls.py @@ -134,7 +134,7 @@ def ls_database(args: argparse.Namespace, cache: str) -> List[FilesRow]: matches_: List[TupleFilesRow] = [] for args_file in args.files: cur.execute( - u"select * from files where name GLOB ? or tar GLOB ?", + "select * from files where name GLOB ? or tar GLOB ?", (args_file, args_file), ) matches_ = matches_ + cur.fetchall() @@ -148,7 +148,7 @@ def ls_database(args: argparse.Namespace, cache: str) -> List[FilesRow]: if args.long: # Get the names of the columns - cur.execute(u"PRAGMA table_info(files);") + cur.execute("PRAGMA table_info(files);") cols = [str(col_info[1]) for col_info in cur.fetchall()] print("\t".join(cols)) @@ -170,7 +170,7 @@ def ls_tars_database(args: argparse.Namespace, cache: str) -> List[TarsRow]: return [] # Find matching files - cur.execute(u"select * from tars") + cur.execute("select * from tars") matches_: List[TupleTarsRow] = cur.fetchall() # Remove duplicates @@ -184,7 +184,7 @@ def ls_tars_database(args: argparse.Namespace, cache: str) -> List[TarsRow]: print("\nTars:") if args.long: # Get the names of the columns - cur.execute(u"PRAGMA table_info(tars);") + cur.execute("PRAGMA table_info(tars);") cols = [str(col_info[1]) for col_info in cur.fetchall()] print("\t".join(cols)) diff --git a/zstash/update.py b/zstash/update.py index 6181f6ce..35d2b6d8 100644 --- a/zstash/update.py +++ b/zstash/update.py @@ -172,7 +172,7 @@ def update_database(args: argparse.Namespace, cache: str) -> Optional[List[str]] size_new = statinfo.st_size # Select the file matching the path. - cur.execute(u"select * from files where name = ?", (file_path,)) + cur.execute("select * from files where name = ?", (file_path,)) new: bool = True while True: # Get the corresponding row in the 'files' table @@ -211,7 +211,7 @@ def update_database(args: argparse.Namespace, cache: str) -> Optional[List[str]] # Find last used tar archive itar: int = -1 - cur.execute(u"select distinct tar from files") + cur.execute("select distinct tar from files") tfiles: List[Tuple[str]] = cur.fetchall() for tfile in tfiles: tfile_string: str = tfile[0] diff --git a/zstash/utils.py b/zstash/utils.py index e73b3cc2..324939c0 100644 --- a/zstash/utils.py +++ b/zstash/utils.py @@ -99,7 +99,7 @@ def update_config(cur: sqlite3.Cursor): # The attribute name does not start with "__" # Get the value (column 2) for attribute `attr` (column 1) # i.e., for the row where column 1 is the attribute, get the value from column 2 - cur.execute(u"select value from config where arg=?", (attr,)) + cur.execute("select value from config where arg=?", (attr,)) value = cur.fetchone()[0] # Update config with the new attribute-value pair setattr(config, attr, value) @@ -108,7 +108,7 @@ def update_config(cur: sqlite3.Cursor): def create_tars_table(cur: sqlite3.Cursor, con: sqlite3.Connection): # Create 'tars' table cur.execute( - u""" + """ create table tars ( id integer primary key, name text, @@ -122,6 +122,6 @@ def create_tars_table(cur: sqlite3.Cursor, con: sqlite3.Connection): def tars_table_exists(cur: sqlite3.Cursor) -> bool: # https://stackoverflow.com/questions/1601151/how-do-i-check-in-sqlite-whether-a-table-exists - cur.execute(u"PRAGMA table_info(tars);") + cur.execute("PRAGMA table_info(tars);") table_info_list: List[TupleTarsRow] = cur.fetchall() return True if table_info_list != [] else False