22# Copyright (C) 2025 Checkmk GmbH - License: GNU General Public License v2
33# This file is part of Checkmk (https://checkmk.com). It is subject to the terms and
44# conditions defined in the file COPYING, which is part of this source code package.
5+ from __future__ import annotations
6+
57import argparse
68import configparser
79import json
1214import socket
1315import subprocess
1416import sys
15- from collections .abc import Callable , Mapping , Sequence
17+ from collections .abc import Mapping , Sequence
1618from dataclasses import dataclass
1719from enum import Enum
1820from pathlib import Path
1921from shutil import which
20- from typing import Any , Literal , TypedDict , TypeVar , Union
22+ from typing import Any , Callable , Literal , TypedDict , TypeVar , Union # noqa: UP035
23+
24+ _F = TypeVar ("_F" , bound = Callable [..., object ])
2125
2226# override decorator is only available in Python 3.12+
2327try :
2428 from typing import override
2529except ImportError :
26- _F = TypeVar ("_F" , bound = Callable [..., object ])
2730
2831 def override (func : _F , / ) -> _F :
2932 return func
@@ -34,7 +37,7 @@ def override(func: _F, /) -> _F:
3437LOGGER = logging .getLogger (__name__ )
3538
3639
37- def parse_arguments (argv : list [str ] | None = None ) -> argparse .Namespace :
40+ def parse_arguments (argv : Sequence [str ] | None = None ) -> argparse .Namespace :
3841 parser = argparse .ArgumentParser (prog = "mk_podman" , description = "Checkmk Podman agent plugin" )
3942 parser .add_argument ("--debug" , action = "store_true" , help = "Debug mode: raise Python exceptions" )
4043 parser .add_argument (
@@ -185,7 +188,7 @@ def load_cfg(cfg_file: Path = DEFAULT_CFG_FILE) -> Union[PodmanConfig, None]:
185188
186189def get_socket_owner (socket_path : Path ) -> Union [str , None ]:
187190 try :
188- return socket_path . owner ()
191+ return pwd . getpwuid ( os . stat ( socket_path ). st_uid ). pw_name
189192 except (OSError , KeyError ):
190193 return None
191194
0 commit comments