home · contact · privacy
Remove obsolete asserts. master
authorChristian Heller <c.heller@plomlompom.de>
Fri, 3 Jan 2025 00:50:35 +0000 (01:50 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Fri, 3 Jan 2025 00:50:35 +0000 (01:50 +0100)
plomtask/days.py
plomtask/db.py
plomtask/http.py
plomtask/processes.py
plomtask/todos.py
tests/utils.py

index 3d9d04182e740d843ffe4c7ec98c68abd6c3a93d..05f93eb8846016c23406fc09346991ec1196f452 100644 (file)
@@ -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:
index dc7564889ef1a5d899002a4a3cc950b1533fc8b6..d83146b069a8a48fa4be96b9663efcdac2b39c3a 100644 (file)
@@ -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'):
index 39981a96e899d77ce7449f7a03f36535b0c5385d..4a5cb53d62b5345c0e283f6daabf60b4174e37be 100644 (file)
@@ -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]
index ff459325e69cce8ae1869173d0381cf951984e59..c90519ba41adb4665dfe1ea380065b23c3473c68 100644 (file)
@@ -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 = []
index 9f9fdb4aadb3c9912b258453dbe507e96f6c4503..03881b5ea220085584c0f8387d3d03d1dfe7765f 100644 (file)
@@ -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)
index 43f6ea4eda15bbf63ba495744ac4bae152b9b391..66b2fbfa3c27cce0c68fefb29b2fda9f7f251fe2 100644 (file)
@@ -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