diff --git a/noxfile.py b/noxfile.py index f056b7a..17d9d37 100644 --- a/noxfile.py +++ b/noxfile.py @@ -1,4 +1,4 @@ -import nox +import nox # type: ignore @nox.session(python=["3.7", "3.8", "3.9"]) diff --git a/src/habitmove/__init__.py b/src/habitmove/__init__.py index fcbc880..6c60766 100644 --- a/src/habitmove/__init__.py +++ b/src/habitmove/__init__.py @@ -4,6 +4,6 @@ import sys try: from importlib.metadata import version as metadata_version except ImportError: - from importlib_metadata import version as metadata_version + from importlib_metadata import version as metadata_version # type: ignore __version__ = str(metadata_version(__name__)) diff --git a/src/habitmove/repetitions.py b/src/habitmove/repetitions.py index 0d1ffa9..63ce416 100644 --- a/src/habitmove/repetitions.py +++ b/src/habitmove/repetitions.py @@ -55,10 +55,11 @@ def habit_list_add_ids(c: sqlite3.Cursor, habitlist: list[Habit]) -> dict[int, H :return habit_id_dict: The habit collection as a dict with the keys consisting of the habit's sqlite database ID. """ - with_id = {} + with_id: dict[int, Habit] = {} for h in habitlist: sql_id = fetch_habit_id(c, h.uuid or "") - with_id[sql_id] = h + if sql_id is not None: + with_id[sql_id] = h return with_id @@ -74,6 +75,8 @@ def fetch_habit_id(cursor: sqlite3.Cursor, uuid: str) -> Optional[int]: if id is not None: return id[0] + return None + def add_to_database( cursor: sqlite3.Cursor, habits: dict[int, Habit], repetition: Repetition