Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 33 additions & 7 deletions podman_compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert formatting changes, ruff format will not like this.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it was because of pre-commit errors

podman_compose.py:65:1: E704 multiple statements on one line (def)
podman_compose.py:69:1: E704 multiple statements on one line (def)
podman_compose.py:276:1: E704 multiple statements on one line (def)
podman_compose.py:280:1: E704 multiple statements on one line (def)
podman_compose.py:284:1: E704 multiple statements on one line (def)

reverted

...


@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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add unit or integration test.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extended the include test that is in project

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.
Expand Down Expand Up @@ -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)
Expand Down
Loading