From: Christian Heller <c.heller@plomlompom.de>
Date: Fri, 3 Jan 2025 00:50:35 +0000 (+0100)
Subject: Remove obsolete asserts.
X-Git-Url: https://plomlompom.com/repos/%7B%7Bdb.prefix%7D%7D/static/%7B%7B%20web_path%20%7D%7D/decks/%27%29;%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20chunks.push%28escapeHTML%28span%5B2%5D%29%29;%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20chunks.push%28%27?a=commitdiff_plain;h=5b10d16b006f1894fde23849e8deb2b866a04700;p=plomtask

Remove obsolete asserts.
---

diff --git a/plomtask/days.py b/plomtask/days.py
index 3d9d041..05f93eb 100644
--- a/plomtask/days.py
+++ b/plomtask/days.py
@@ -42,7 +42,6 @@ class Day(BaseModel[str]):
         and also ensures we're looking for proper dates and not strings like
         "yesterday" by enforcing the valid_date translation.
         """
-        assert isinstance(id_, str)
         possibly_translated_date = valid_date(id_)
         day = super().by_id(db_conn, possibly_translated_date)
         if day.id_ in Todo.days_to_update:
diff --git a/plomtask/db.py b/plomtask/db.py
index dc75648..d83146b 100644
--- a/plomtask/db.py
+++ b/plomtask/db.py
@@ -388,7 +388,6 @@ class BaseModel(Generic[BaseModelId]):
         cache = cls.get_cache()
         if id_ in cache:
             obj = cache[id_]
-            assert isinstance(obj, cls)
             return obj
         return None
 
@@ -480,7 +479,6 @@ class BaseModel(Generic[BaseModelId]):
         """
         items: dict[BaseModelId, BaseModelInstance] = {}
         for k, v in cls.get_cache().items():
-            assert isinstance(v, cls)
             items[k] = v
         already_recorded = items.keys()
         for id_ in db_conn.column_all(cls.table_name, 'id'):
diff --git a/plomtask/http.py b/plomtask/http.py
index 39981a9..4a5cb53 100644
--- a/plomtask/http.py
+++ b/plomtask/http.py
@@ -227,7 +227,6 @@ class TaskHandler(BaseHTTPRequestHandler):
 
         def clear_caches() -> None:
             for cls in (Day, Todo, Condition, Process, ProcessStep):
-                assert hasattr(cls, 'empty_cache')
                 cls.empty_cache()
 
         def decorator(f: Callable[..., str | None]
diff --git a/plomtask/processes.py b/plomtask/processes.py
index ff45932..c90519b 100644
--- a/plomtask/processes.py
+++ b/plomtask/processes.py
@@ -63,7 +63,6 @@ class Process(BaseModel[int], ConditionsRelations):
         assert process.id_ is not None
         for name in ('conditions', 'blockers', 'enables', 'disables'):
             table = f'process_{name}'
-            assert isinstance(process.id_, int)
             for c_id in db_conn.column_where(table, 'condition',
                                              'process', process.id_):
                 target = getattr(process, name)
@@ -129,7 +128,6 @@ class Process(BaseModel[int], ConditionsRelations):
         top_owner = external_owner or self
         for step in [s for s in self.explicit_steps
                      if s.parent_step_id is None]:
-            assert isinstance(step.id_, int)
             new_node = make_node(step, step in top_owner.suppressed_steps)
             step_nodes += [new_node]
         for step_node in step_nodes:
@@ -196,7 +194,6 @@ class Process(BaseModel[int], ConditionsRelations):
             for step in step_process.explicit_steps:
                 walk_steps(step)
 
-        assert isinstance(self.id_, int)
         # NB: separate the collection of steps to save/remove from the action
         # because the latter may modify the collection / self.explicit_steps
         to_remove = []
diff --git a/plomtask/todos.py b/plomtask/todos.py
index 9f9fdb4..03881b5 100644
--- a/plomtask/todos.py
+++ b/plomtask/todos.py
@@ -146,7 +146,6 @@ class Todo(BaseModel[int], ConditionsRelations):
             todo.parents += [cls.by_id(db_conn, t_id)]
         for name in ('conditions', 'blockers', 'enables', 'disables'):
             table = f'todo_{name}'
-            assert isinstance(todo.id_, int)
             for cond_id in db_conn.column_where(table, 'condition',
                                                 'todo', todo.id_):
                 target = getattr(todo, name)
diff --git a/tests/utils.py b/tests/utils.py
index 43f6ea4..66b2fbf 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -223,7 +223,6 @@ class TestCaseWithDB(TestCaseAugmented):
         hashes_content = [hash(x) for x in content]
         db_found: list[Any] = []
         for item in content:
-            assert isinstance(item.id_, type(self.default_ids[0]))
             db_found += self._load_from_db(item.id_)
         hashes_db_found = [hash(x) for x in db_found]
         self.assertEqual(sorted(hashes_content), sorted(hashes_db_found))
@@ -410,7 +409,6 @@ class TestCaseWithDB(TestCaseAugmented):
         id_ = self.default_ids[0]
         obj = self._make_from_defaults(id_)
         obj.save(self.db_conn)
-        assert isinstance(obj.id_, type(id_))
         for row in self.db_conn.row_where(self.checked_class.table_name,
                                           'id', obj.id_):
             # check .from_table_row reproduces state saved, no matter if obj