Fix all linting errors

This commit is contained in:
Jacob Hinkle 2022-09-28 13:51:22 -04:00
parent 36b1038861
commit 630231ab63
9 changed files with 20 additions and 30 deletions

View File

@ -29,7 +29,7 @@ def version():
@click.group( @click.group(
cls=AliasedGroup, help=f"Composable provenance tracking for scientific data" cls=AliasedGroup, help="Composable provenance tracking for scientific data"
) )
@click.option( @click.option(
"-L", "-L",

View File

@ -1,7 +1,7 @@
import click import click
from loguru import logger from loguru import logger
from .. import db, fs from .. import fs
from ..store import find_store, Store from ..store import find_store, Store
import os import os
@ -15,7 +15,7 @@ def print_diff(
"""Pretty print an FSDiff object""" """Pretty print an FSDiff object"""
if use_color: if use_color:
try: try:
from colorama import init, Fore, Back, Style from colorama import init, Fore, Back, Style # NOQA
except ImportError: except ImportError:
warnings.warn("Could not import colorama library. Color output disabled.") warnings.warn("Could not import colorama library. Color output disabled.")
use_color = False use_color = False
@ -63,14 +63,14 @@ def print_diff(
relpath, relpath,
) )
for l, d in ABdiff.flatten_tree(): for lev, d in ABdiff.flatten_tree():
if d.A is None: if d.A is None:
assert d.B is not None assert d.B is not None
_print_row("NEW", d.B, l) _print_row("NEW", d.B, lev)
elif d.B is None: elif d.B is None:
_print_row("DEL", d.A, l) _print_row("DEL", d.A, lev)
elif d.A.sha256 != d.B.sha256: elif d.A.sha256 != d.B.sha256:
_print_row("MOD", d.B, l) _print_row("MOD", d.B, lev)
@click.command() @click.command()

View File

@ -1,7 +1,7 @@
import click import click
from loguru import logger from loguru import logger
from .. import fs, store from .. import store
from .common import confirm from .common import confirm
from .diff import print_diff from .diff import print_diff

View File

@ -1,6 +1,6 @@
import importlib.resources import importlib.resources
import os
import sqlite3 import sqlite3
import warnings
# This will match the user_version in any nancy.db initialized by this process # This will match the user_version in any nancy.db initialized by this process
@ -19,7 +19,7 @@ if (
or sub < min_sqlite_version[1] or sub < min_sqlite_version[1]
or minor < min_sqlite_version[2] or minor < min_sqlite_version[2]
): ):
warning.warn( warnings.warn(
f"Minimum sqlite version is {min_sqlite_verstr}. Found {sqlite_verstr}" f"Minimum sqlite version is {min_sqlite_verstr}. Found {sqlite_verstr}"
) )

View File

@ -5,7 +5,6 @@ import json
import os import os
import platform import platform
import sys import sys
import time
class Environment(NamedTuple): class Environment(NamedTuple):

View File

@ -2,12 +2,11 @@
from loguru import logger from loguru import logger
from dataclasses import asdict, dataclass from dataclasses import dataclass
from datetime import datetime from datetime import datetime
import hashlib import hashlib
import operator import operator
import os import os
from pathlib import Path
import stat import stat
from typing import List from typing import List
import warnings import warnings
@ -295,22 +294,15 @@ class FSEntry:
) )
cursor.execute( cursor.execute(
f""" "SELECT id, name, frozen FROM filedir WHERE parent=?",
SELECT id, name, frozen
FROM filedir
WHERE parent=?
""",
(root_id,), (root_id,),
) )
rows = cursor.fetchall() rows = cursor.fetchall()
ob.children = [cls.from_db_index(cursor, root_row=r, parent=ob) for r in rows] ob.children = [cls.from_db_index(cursor, root_row=r, parent=ob) for r in rows]
# get all versions # get all versions
fields = ""
cursor.execute( cursor.execute(
f""" "SELECT * FROM filedir_version WHERE filedir=? ORDER BY recorded_time",
SELECT * FROM filedir_version WHERE filedir=? ORDER BY recorded_time
""",
(root_id,), (root_id,),
) )
matches = cursor.fetchall() matches = cursor.fetchall()
@ -349,8 +341,8 @@ class FSEntry:
# versions: [FSEntryVersion] = [] # versions: [FSEntryVersion] = []
return "\n".join( return "\n".join(
(" " * level) + l (" " * level) + line
for l in f"""id: {self.id} for line in f"""id: {self.id}
filename: {self.filename} filename: {self.filename}
relpath: {self.relpath} relpath: {self.relpath}
parent (relpath): {'None' if self.parent is None else self.parent.relpath} parent (relpath): {'None' if self.parent is None else self.parent.relpath}

View File

@ -42,7 +42,7 @@ class Program:
None, # end_time REAL, None, # end_time REAL,
os.getpid(), # process_id INTEGER, -- host PID of python process on host OS os.getpid(), # process_id INTEGER, -- host PID of python process on host OS
env.id, # environment INTEGER NOT NULL, env.id, # environment INTEGER NOT NULL,
self.message, # message TEXT, -- user-defined message to help distinguish similar runs self.message, # user-defined message to help distinguish similar runs
), ),
) )
self.id = cur.lastrowid self.id = cur.lastrowid
@ -81,7 +81,8 @@ class Program:
self._evaluated = True # prevent re-running self._evaluated = True # prevent re-running
elapsed = end_time - self.start_time elapsed = end_time - self.start_time
logger.success( logger.success(
f"Program [{self.id}] {self.name} (message:{self.message}) ran in {elapsed} seconds." f"Program [{self.id}] {self.name} "
f"(message:{self.message}) ran in {elapsed} seconds."
) )
@ -153,8 +154,6 @@ class Store:
"""Get the database id for the table entry in this store having name '.'""" """Get the database id for the table entry in this store having name '.'"""
if cur is None: if cur is None:
cur = self.conn.cursor() cur = self.conn.cursor()
cur.execute("SELECT * FROM filedir")
allfiledir = cur.fetchall()
cur.execute("SELECT id FROM filedir WHERE store=1 AND parent is NULL") cur.execute("SELECT id FROM filedir WHERE store=1 AND parent is NULL")
(root_id,) = cur.fetchone() (root_id,) = cur.fetchone()
return root_id return root_id

View File

@ -1,4 +1,4 @@
from . import machine, store from . import machine
import getpass import getpass
import os import os

View File

@ -1,3 +1,3 @@
from .db import schema_version from .db import schema_version # NOQA
__version__ = "0.1.0" __version__ = "0.1.0"