]> Nutra Git (v1) - nutratech/cli.git/commitdiff
fix python 3.5 type annotations
authorShane Jaroch <chown_tee@proton.me>
Fri, 19 Apr 2024 17:39:04 +0000 (13:39 -0400)
committerShane Jaroch <chown_tee@proton.me>
Fri, 19 Apr 2024 17:39:04 +0000 (13:39 -0400)
ntclient/argparser/funcs.py
ntclient/persistence/sql/__init__.py
ntclient/persistence/sql/nt/__init__.py
ntclient/persistence/sql/usda/__init__.py
ntclient/persistence/sql/usda/funcs.py
ntclient/services/bugs.py
ntclient/services/usda.py

index b9f27a01419ec2345f5b386b55814a4cf507ada4..ff8499d622f97142298fc6d0c53f75a8b2c75280 100644 (file)
@@ -350,13 +350,13 @@ def bug_simulate(args: argparse.Namespace) -> tuple:
     raise NotImplementedError("This service intentionally raises an error, for testing")
 
 
-def bugs_list(args: argparse.Namespace) -> tuple[int, list]:
+def bugs_list(args: argparse.Namespace) -> tuple:
     """List bug reports that have been saved"""
     return ntclient.services.bugs.list_bugs(show_all=args.show)
 
 
 # pylint: disable=unused-argument
-def bugs_report(args: argparse.Namespace) -> tuple[int, int]:
+def bugs_report(args: argparse.Namespace) -> tuple:
     """Report bugs"""
     n_submissions = ntclient.services.bugs.submit_bugs()
     return 0, n_submissions
index a7fe8cf98a06d030f27dfc450fca10c830be2763..8e2e40ffa6ca971789d1ed48440b938adbdc1d0d 100644 (file)
@@ -2,7 +2,6 @@
 
 import sqlite3
 from collections.abc import Sequence
-from typing import Optional
 
 from ntclient.utils import CLI_CONFIG
 
@@ -11,7 +10,7 @@ from ntclient.utils import CLI_CONFIG
 # ------------------------------------------------
 
 
-def sql_entries(sql_result: sqlite3.Cursor) -> Sequence[list, list, int, Optional[int]]:
+def sql_entries(sql_result: sqlite3.Cursor) -> tuple:
     """
     Formats and returns a `sql_result()` for console digestion and output
     FIXME: the IDs are not necessarily integers, but are unique.
@@ -99,7 +98,7 @@ def _sql(
     query: str,
     db_name: str,
     values: Sequence = (),
-) -> tuple[list, list, int, Optional[int]]:
+) -> tuple:
     """@param values: tuple | list"""
 
     cur = _prep_query(con, query, db_name, values)
index ef19816a4982a39ec8bf3b0f72c079e0fce98344..5c711c9e3dc542b0e42f6a2db0c01391ffa127cd 100644 (file)
@@ -3,7 +3,6 @@
 import os
 import sqlite3
 from collections.abc import Sequence
-from typing import Optional
 
 from ntclient import (
     NT_DB_NAME,
@@ -81,7 +80,7 @@ def nt_sqlite_connect(version_check: bool = True) -> sqlite3.Connection:
     raise SqlConnectError("ERROR: nt database doesn't exist, please run `nutra init`")
 
 
-def sql(query: str, values: Sequence = ()) -> tuple[list, list, int, Optional[int]]:
+def sql(query: str, values: Sequence = ()) -> tuple:
     """Executes a SQL command to nt.sqlite3"""
 
     con = nt_sqlite_connect()
index 419494eb158867a9e1cea8f08401e5865e0fb1a3..ac4110769af7a2ec8b5af0a0897cd514f4880006 100644 (file)
@@ -5,7 +5,6 @@ import sqlite3
 import tarfile
 import urllib.request
 from collections.abc import Sequence
-from typing import Optional
 
 from ntclient import NUTRA_HOME, USDA_DB_NAME, __db_target_usda__
 from ntclient.persistence.sql import _sql, version
@@ -99,9 +98,7 @@ def usda_ver() -> str:
     return version(con)
 
 
-def sql(
-    query: str, values: Sequence = (), version_check: bool = True
-) -> tuple[list, list, int, Optional[int]]:
+def sql(query: str, values: Sequence = (), version_check: bool = True) -> tuple:
     """
     Executes a SQL command to usda.sqlite3
 
index fb4e435ced558165389d369ccb80d1334c72d47f..6ed57202deb38f53002982e331bd9e0cab4e4369 100644 (file)
@@ -27,7 +27,7 @@ def sql_food_details(_food_ids: set = None) -> list:  # type: ignore
         query = query % food_ids
 
     rows, _, _, _ = sql(query)
-    return rows
+    return list(rows)
 
 
 def sql_nutrients_overview() -> dict:
@@ -38,7 +38,7 @@ def sql_nutrients_overview() -> dict:
     return {x[0]: x for x in rows}
 
 
-def sql_nutrients_details() -> tuple[list, list]:
+def sql_nutrients_details() -> tuple:
     """Shows nutrients 'details'"""
 
     query = "SELECT * FROM nutrients_overview;"
@@ -64,7 +64,7 @@ WHERE
     # FIXME: support this kind of thing by library code & parameterized queries
     food_ids = ",".join(str(x) for x in set(_food_ids))
     rows, _, _, _ = sql(query % food_ids)
-    return rows
+    return list(rows)
 
 
 def sql_analyze_foods(food_ids: set) -> list:
@@ -83,7 +83,7 @@ WHERE
     # TODO: parameterized queries
     food_ids_concat = ",".join(str(x) for x in set(food_ids))
     rows, _, _, _ = sql(query % food_ids_concat)
-    return rows
+    return list(rows)
 
 
 ################################################################################
@@ -107,7 +107,7 @@ ORDER BY
 """
     # TODO: parameterized queries
     rows, _, _, _ = sql(query % (NUTR_ID_KCAL, nutrient_id))
-    return rows
+    return list(rows)
 
 
 def sql_sort_foods(nutr_id: int) -> list:
@@ -134,7 +134,7 @@ ORDER BY
 """
     # TODO: parameterized queries
     rows, _, _, _ = sql(query % nutr_id)
-    return rows
+    return list(rows)
 
 
 def sql_sort_foods_by_kcal(nutr_id: int) -> list:
@@ -164,4 +164,4 @@ ORDER BY
 """
     # TODO: parameterized queries
     rows, _, _, _ = sql(query % nutr_id)
-    return rows
+    return list(rows)
index 8accb1c2b7686ac333284e29b9af24d0de7d64aa..7843afff75aab33020fafb890fbb39b16a50591f 100644 (file)
@@ -73,7 +73,7 @@ def _list_bugs() -> list:
     return bugs
 
 
-def list_bugs(show_all: bool) -> tuple[int, list]:
+def list_bugs(show_all: bool) -> tuple:
     """List all bugs, with headers.  Returns (exit_code, bugs: list[dict])."""
 
     bugs = _list_bugs()
index c4f2f947ee7cd8fbe46cbecc760c2e94fc8f1c83..c3a3c5910485c839dc7ef364e01c6bd3ecd16640 100644 (file)
@@ -6,7 +6,6 @@ Created on Sat Oct 27 20:28:06 2018
 """
 
 import pydoc
-from typing import Sequence, Optional
 
 from tabulate import tabulate
 
@@ -62,9 +61,7 @@ def sort_foods(
 
     # TODO: sub shrt_desc for long if available, and support config.FOOD_NAME_TRUNC
 
-    def print_results(
-        _results: list[list[Optional[float]]], _nutrient_id: int
-    ) -> None:
+    def print_results(_results: list, _nutrient_id: int) -> None:
         """Prints truncated list for sort"""
         nutrients = sql_nutrients_overview()
         nutrient = nutrients[_nutrient_id]