From 23c7ff7f9833ff5b0e547c19a4ad85325a5d3400 Mon Sep 17 00:00:00 2001
From: Christian Heller <c.heller@plomlompom.de>
Date: Thu, 25 Apr 2024 06:07:25 +0200
Subject: [PATCH] Remove asserts no longer needed.

---
 plomtask/conditions.py | 3 ---
 plomtask/days.py       | 2 --
 plomtask/db.py         | 1 -
 plomtask/http.py       | 1 -
 plomtask/processes.py  | 1 -
 plomtask/todos.py      | 3 ---
 6 files changed, 11 deletions(-)

diff --git a/plomtask/conditions.py b/plomtask/conditions.py
index 4b01249..b2ecda1 100644
--- a/plomtask/conditions.py
+++ b/plomtask/conditions.py
@@ -24,7 +24,6 @@ class Condition(BaseModel[int]):
                        row: Row | list[Any]) -> Condition:
         """Build condition from row, including VersionedAttributes."""
         condition = super().from_table_row(db_conn, row)
-        assert isinstance(condition, Condition)
         for name in ('title', 'description'):
             table_name = f'condition_{name}s'
             for row_ in db_conn.row_where(table_name, 'parent', row[0]):
@@ -57,7 +56,6 @@ class Condition(BaseModel[int]):
                 raise NotFoundException(f'Condition not found of id: {id_}')
             condition = cls(id_, False)
             condition.save(db_conn)
-        assert isinstance(condition, Condition)
         return condition
 
     def save(self, db_conn: DatabaseConnection) -> None:
@@ -65,7 +63,6 @@ class Condition(BaseModel[int]):
         self.save_core(db_conn)
         self.title.save(db_conn)
         self.description.save(db_conn)
-        assert isinstance(self.id_, int)
 
 
 class ConditionsRelations:
diff --git a/plomtask/days.py b/plomtask/days.py
index 5fe984b..ce11200 100644
--- a/plomtask/days.py
+++ b/plomtask/days.py
@@ -72,13 +72,11 @@ class Day(BaseModel[str]):
         """Retrieve Day by date if in DB (prefer cache), else return None."""
         day, _ = super()._by_id(db_conn, date)
         if day:
-            assert isinstance(day, Day)
             return day
         if not create:
             raise NotFoundException(f'Day not found for date: {date}')
         day = cls(date)
         day.cache()
-        assert isinstance(day, Day)
         return day
 
     @property
diff --git a/plomtask/db.py b/plomtask/db.py
index e8a542e..bf2b79f 100644
--- a/plomtask/db.py
+++ b/plomtask/db.py
@@ -145,7 +145,6 @@ class BaseModel(Generic[X]):
         else:
             for row in db_conn.row_where(cls.table_name, 'id', id_):
                 obj = cls.from_table_row(db_conn, row)
-                assert isinstance(obj, cls)
                 obj.cache()
                 break
         return obj, from_cache
diff --git a/plomtask/http.py b/plomtask/http.py
index d7be135..c848600 100644
--- a/plomtask/http.py
+++ b/plomtask/http.py
@@ -245,7 +245,6 @@ class TaskHandler(BaseHTTPRequestHandler):
         process.set_enables(self.conn, self.form_data.get_all_int('enables'))
         process.set_disables(self.conn, self.form_data.get_all_int('disables'))
         process.save_core(self.conn)
-        assert process.id_ is not None  # for mypy
         process.explicit_steps = []
         steps: list[tuple[int | None, int, int | None]] = []
         for step_id in self.form_data.get_all_int('steps'):
diff --git a/plomtask/processes.py b/plomtask/processes.py
index 590c5bc..654e5fc 100644
--- a/plomtask/processes.py
+++ b/plomtask/processes.py
@@ -208,7 +208,6 @@ class ProcessStep(BaseModel[int]):
         """Retrieve ProcessStep by id_, or throw NotFoundException."""
         step, _ = super()._by_id(db_conn, id_)
         if step:
-            assert isinstance(step, ProcessStep)
             return step
         raise NotFoundException(f'found no ProcessStep of ID {id_}')
 
diff --git a/plomtask/todos.py b/plomtask/todos.py
index 0b42d47..5901571 100644
--- a/plomtask/todos.py
+++ b/plomtask/todos.py
@@ -76,7 +76,6 @@ class Todo(BaseModel[int], ConditionsRelations):
                                                     'todo', todo.id_):
                     target = getattr(todo, name)
                     target += [Condition.by_id(db_conn, cond_id)]
-        assert isinstance(todo, Todo)
         return todo
 
     @classmethod
@@ -135,7 +134,6 @@ class Todo(BaseModel[int], ConditionsRelations):
                        if s.parent_step_id is None]
         for child_process_id in [c.process.id_ for c in self.children]:
             if child_process_id in unsatisfied:
-                assert isinstance(child_process_id, int)
                 unsatisfied.remove(child_process_id)
         return unsatisfied
 
@@ -194,7 +192,6 @@ class Todo(BaseModel[int], ConditionsRelations):
                                   and (c not in potentially_enabled)]:
                     children += [make_node(condition)]
             else:
-                assert isinstance(step, Condition)
                 seen = step.id_ in seen_conditions
                 seen_conditions.add(step.id_)
             return TodoStepsNode(step, is_todo, children, seen)
-- 
2.30.2