Skip to content

Commit

Permalink
Remove useless monkeypatch in server/parsec/__main__.py (already do…
Browse files Browse the repository at this point in the history
…ne in `server/parsec/cli/__init__.py`)
  • Loading branch information
touilleMan committed Dec 23, 2024
1 parent f5d3d17 commit 388b6ed
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 25 deletions.
23 changes: 0 additions & 23 deletions server/parsec/__main__.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,7 @@
# Parsec Cloud (https://parsec.cloud) Copyright (c) BUSL-1.1 2016-present Scille SAS
from __future__ import annotations

import os
import sys
from typing import Any, Sequence

from parsec.cli import cli

# Add support for PARSEC_CMD_ARGS env var

vanilla_cli_main = cli.main


def patched_cli_main(args: Sequence[str] | None = None, **kwargs: Any) -> Any:
args_list = list(args) if args is not None else sys.argv[1:]

raw_extra_args = os.environ.get("PARSEC_CMD_ARGS", "")
args_list += [os.path.expandvars(x) for x in raw_extra_args.split()]

return vanilla_cli_main(args=args_list[:], **kwargs)


# [pyright] here we want to use the patched main instead of the one provided by `BaseCommand`
# Note: We could use monkeypatch instead :thinking:
cli.main = patched_cli_main # pyright: ignore[reportAttributeAccessIssue]


if __name__ == "__main__":
cli()
2 changes: 0 additions & 2 deletions server/parsec/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,4 @@ def patched_cli_main(args: Sequence[str] | None = None, **kwargs: Any) -> Any:
return vanilla_cli_main(args=args_list[:], **kwargs)


# [pyright] here we want to use the patched main instead of the one provided by `BaseCommand`
# Note: We could use monkeypatch instead :thinking:
cli.main = patched_cli_main # pyright: ignore[reportAttributeAccessIssue]

0 comments on commit 388b6ed

Please sign in to comment.