Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update black to fix click ImportError #205

Merged
merged 1 commit into from
Apr 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion conda/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions zstash/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions zstash/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def extract_database(
if args.files != ["*"]:
raise ValueError("If --tars is used, <files> 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
Expand All @@ -221,15 +221,15 @@ 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()
else:
# 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()
Expand Down
4 changes: 2 additions & 2 deletions zstash/hpss_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions zstash/ls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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))

Expand All @@ -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
Expand All @@ -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))

Expand Down
4 changes: 2 additions & 2 deletions zstash/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down
6 changes: 3 additions & 3 deletions zstash/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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,
Expand All @@ -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