Skip to content

Commit

Permalink
Fix some mypy type issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Josef-Friedrich committed Mar 8, 2024
1 parent 87bc99b commit 067b50e
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions check_systemd.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,21 +376,22 @@ class Unit(BaseUnit):
def __check_active_state(state: object) -> ActiveState:
states: tuple[ActiveState] = get_args(ActiveState)
if state in states:
return state
# https://github.com/python/mypy/issues/9718
return state # type: ignore
raise ValueError(f"Invalid active state: {state}")

@staticmethod
def __check_sub_state(state: object) -> SubState:
states: tuple[SubState] = get_args(SubState)
if state in states:
return state
return state # type: ignore
raise ValueError(f"Invalid sub state: {state}")

@staticmethod
def __check_load_state(state: object) -> LoadState:
states: tuple[LoadState] = get_args(LoadState)
if state in states:
return state
return state # type: ignore
raise ValueError(f"Invalid load state: {state}")

def __init__(
Expand Down Expand Up @@ -860,9 +861,9 @@ def __execute_cli(args: str | Sequence[str]) -> str | None:
raise CheckError(stderr)

if stdout:
stdout = stdout.decode("utf-8")
logger.verbose("stdout:\n%s", stdout)
return stdout
result = stdout.decode("utf-8")
logger.verbose("stdout:\n%s", result)
return result
return None

@staticmethod
Expand Down Expand Up @@ -894,7 +895,7 @@ def __convert_to_sec(fmt_timespan: str) -> float:
"s": 1,
"ms": 0.001,
}
result = 0
result: float = 0
for span in fmt_timespan.split():
match = re.search(r"([\d\.]+)([a-z]+)", span)
if match:
Expand Down Expand Up @@ -1081,7 +1082,7 @@ def __init__(

@property
def _bus_type(self) -> BusType:
if not BusType:
if not BusType is not None:
raise Exception("The package PyGObject (gi) is not available.")
return BusType.SESSION if self._user else BusType.SYSTEM

Expand Down

0 comments on commit 067b50e

Please sign in to comment.