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(
cls=AliasedGroup, help=f"Composable provenance tracking for scientific data"
cls=AliasedGroup, help="Composable provenance tracking for scientific data"
)
@click.option(
"-L",

View File

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

View File

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

View File

@ -1,6 +1,6 @@
import importlib.resources
import os
import sqlite3
import warnings
# 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 minor < min_sqlite_version[2]
):
warning.warn(
warnings.warn(
f"Minimum sqlite version is {min_sqlite_verstr}. Found {sqlite_verstr}"
)

View File

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

View File

@ -2,12 +2,11 @@
from loguru import logger
from dataclasses import asdict, dataclass
from dataclasses import dataclass
from datetime import datetime
import hashlib
import operator
import os
from pathlib import Path
import stat
from typing import List
import warnings
@ -295,22 +294,15 @@ class FSEntry:
)
cursor.execute(
f"""
SELECT id, name, frozen
FROM filedir
WHERE parent=?
""",
"SELECT id, name, frozen FROM filedir WHERE parent=?",
(root_id,),
)
rows = cursor.fetchall()
ob.children = [cls.from_db_index(cursor, root_row=r, parent=ob) for r in rows]
# get all versions
fields = ""
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,),
)
matches = cursor.fetchall()
@ -349,8 +341,8 @@ class FSEntry:
# versions: [FSEntryVersion] = []
return "\n".join(
(" " * level) + l
for l in f"""id: {self.id}
(" " * level) + line
for line in f"""id: {self.id}
filename: {self.filename}
relpath: {self.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,
os.getpid(), # process_id INTEGER, -- host PID of python process on host OS
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
@ -81,7 +81,8 @@ class Program:
self._evaluated = True # prevent re-running
elapsed = end_time - self.start_time
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 '.'"""
if cur is None:
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")
(root_id,) = cur.fetchone()
return root_id

View File

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

View File

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