diff --git a/podman_compose.py b/podman_compose.py index 46725ffd..3826953d 100755 --- a/podman_compose.py +++ b/podman_compose.py @@ -62,9 +62,13 @@ def filteri(a: list[str]) -> list[str]: @overload -def try_int(i: int | str, fallback: int) -> int: ... +def try_int(i: int | str, fallback: int) -> int: + ... + + @overload -def try_int(i: int | str, fallback: None) -> int | None: ... +def try_int(i: int | str, fallback: None) -> int | None: + ... def try_int(i: int | str, fallback: int | None = None) -> int | None: @@ -271,11 +275,18 @@ def fix_mount_dict( @overload -def rec_subs(value: dict, subs_dict: dict[str, Any]) -> dict: ... +def rec_subs(value: dict, subs_dict: dict[str, Any]) -> dict: + ... + + @overload -def rec_subs(value: str, subs_dict: dict[str, Any]) -> str: ... +def rec_subs(value: str, subs_dict: dict[str, Any]) -> str: + ... + + @overload -def rec_subs(value: Iterable, subs_dict: dict[str, Any]) -> Iterable: ... +def rec_subs(value: Iterable, subs_dict: dict[str, Any]) -> Iterable: + ... def rec_subs(value: dict | str | Iterable, subs_dict: dict[str, Any]) -> dict | str | Iterable: @@ -2376,7 +2387,18 @@ def _parse_compose_file(self) -> None: # If `include` is used, append included files to files include = compose.get("include") if include: - files.extend([os.path.join(os.path.dirname(filename), i) for i in include]) + # Check if 'include' block is dict or list of strings + for i in include: + if isinstance(i, str): + files.append(os.path.join(os.path.dirname(filename), i)) + elif isinstance(i, dict): + path = i.get("path") + if path: + # Extend files list with values from path key + files.extend([os.path.join(os.path.dirname(filename), p) for p in path]) + elif not path: + # Raise error if path is missing + raise RuntimeError("Please use 'path' as key in include block") # As compose obj is updated and tested with every loop, not deleting `include` # from it, results in it being tested again and again, original values for # `include` be appended to `files`, and, included files be processed for ever. @@ -2569,7 +2591,11 @@ def _parse_args(self, argv: list[str] | None = None) -> argparse.Namespace: subparsers = parser.add_subparsers(title="command", dest="command") _ = subparsers.add_parser("help", help="show help") for cmd_name, cmd in self.commands.items(): - subparser = subparsers.add_parser(cmd_name, help=cmd.help, description=cmd.desc) # pylint: disable=protected-access + subparser = subparsers.add_parser( + cmd_name, + help=cmd.help, + description=cmd.desc + ) # pylint: disable=protected-access for cmd_parser in cmd._parse_args: # pylint: disable=protected-access cmd_parser(subparser) self.global_args = parser.parse_args(argv)