]> Nutra Git (v2) - nutratech/nt-sqlite.git/commitdiff
resolve some mypy errors? Idk about this verbosity
authorShane Jaroch <chown_tee@proton.me>
Tue, 19 Jul 2022 14:54:01 +0000 (10:54 -0400)
committerShane Jaroch <chown_tee@proton.me>
Tue, 19 Jul 2022 14:54:01 +0000 (10:54 -0400)
sql/__init__.py

index dfbe0341b239926ab682fd054e27f739472d735e..78326cffe408d84d8aa4f2642f72287ad30e8940 100755 (executable)
@@ -10,7 +10,7 @@ SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
 CSV_DATA_DIR = os.path.join(SCRIPT_DIR, "data")
 
 
-def build_ntsqlite(verbose=False) -> bool:
+def build_ntsqlite(verbose: bool = False) -> bool:
     """Builds and inserts stock data into nt.sqlite3"""
     # cd into this script's directory
     os.chdir(SCRIPT_DIR)
@@ -43,7 +43,7 @@ def build_ntsqlite(verbose=False) -> bool:
         # Loop over CSV files
         with open(file_path_full, encoding="utf-8") as csv_file:
             dict_reader = csv.DictReader(csv_file)
-            values = ",".join("?" * len(dict_reader.fieldnames))
+            values = ",".join("?" * len(dict_reader.fieldnames or []))
             reader = csv.reader(csv_file)
             # pylint: disable=consider-using-f-string
             query = "INSERT INTO {0} VALUES ({1});".format(  # nosec: B608