home · contact · privacy
Remove asserts no longer needed.
authorChristian Heller <c.heller@plomlompom.de>
Thu, 25 Apr 2024 04:07:25 +0000 (06:07 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Thu, 25 Apr 2024 04:07:25 +0000 (06:07 +0200)
plomtask/conditions.py
plomtask/days.py
plomtask/db.py
plomtask/http.py
plomtask/processes.py
plomtask/todos.py

index 4b012491d6151ed74995849378fa8dc1c04f20f8..b2ecda14cb7cef0b5bf350d1a253389ea32aabb7 100644 (file)
@@ -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:
index 5fe984b7c49596121246bb7e822c8b4bb1536139..ce112006042681ba059bc5129d7c45bb3d8c6d21 100644 (file)
@@ -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
index e8a542e6176937a7c205a9a5909a5c776bdbd7db..bf2b79f758b313525816581620a792330fdbd9a2 100644 (file)
@@ -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
index d7be135ee03baf997aca63ef09c55aae4a4350a6..c8486003ce48fb785474432f512b08a380193a32 100644 (file)
@@ -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'):
index 590c5bca56d3f84c1b67f34ee3f80c084903b1c9..654e5fcb7d8c8659b7c034e427767893b90a84b4 100644 (file)
@@ -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_}')
 
index 0b42d47b3604bb50885c4cda69dcbfb5f263afc8..5901571d6e2e52c1539e48587d6e8ea7590fb1d1 100644 (file)
@@ -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)