improved code by mypy advice

This commit is contained in:
2024-12-15 18:05:44 +01:00
parent 8cb98e102f
commit 4522c0dd9e
2 changed files with 6 additions and 2 deletions
+4 -1
View File
@@ -1,6 +1,6 @@
from app_class import AppClass from app_class import AppClass
from config import Config from config import Config
from cpufreq import cpuFreq, cpufreq from cpufreq import cpuFreq, cpufreq # type: ignore
from functools import cached_property from functools import cached_property
from mapping import governor_priority_mapping from mapping import governor_priority_mapping
from exceptions import GovernorNotFound from exceptions import GovernorNotFound
@@ -46,6 +46,9 @@ class Governor(AppClass):
self.log.warning("application is running in testmode, cpu governor not set") self.log.warning("application is running in testmode, cpu governor not set")
return None return None
if self._cpufreq is None:
return None
if governor_name not in self._cpufreq.available_governors: if governor_name not in self._cpufreq.available_governors:
self.log.error("governor %s not supported by cpu", governor_name) self.log.error("governor %s not supported by cpu", governor_name)
return None return None
+2 -1
View File
@@ -2,12 +2,13 @@ from app_class import AppClass
from config import Config from config import Config
from trigger import Trigger from trigger import Trigger
import asyncio import asyncio
from asyncio import Task
class TriggerScheduler(AppClass): class TriggerScheduler(AppClass):
def __init__(self, _config: Config) -> None: def __init__(self, _config: Config) -> None:
super().__init__(_config) super().__init__(_config)
self.tasks = [] self.tasks: list[Task] = []
async def trigger(self, _trigger: Trigger) -> None: async def trigger(self, _trigger: Trigger) -> None:
"""Run a trigger with a specific name at a given interval.""" """Run a trigger with a specific name at a given interval."""