Skip to content

Commit 0bb260e

Browse files
committed
Update install.py
1 parent 01f71f1 commit 0bb260e

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

.devcontainer/install.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -775,28 +775,28 @@ def _snake_case_to_camel_case(string: str) -> str:
775775

776776

777777
def _parse_args() -> _argparse.Namespace:
778-
779-
def source_list(value):
778+
def source_list(value: str) -> list[str]:
780779
"""Ensure the input is a comma-separated list of valid choices."""
781-
VALID_CHOICES = ["conda", "pip", "apt", "brew", "choco", "winget", "bash", "pwsh"]
782780
items = value.split(",")
783-
invalid = [item for item in items if item not in VALID_CHOICES]
781+
invalid = [item for item in items if item not in valid_sources]
784782
if invalid:
785-
raise _argparse.ArgumentTypeError(
786-
f"Invalid choices: {', '.join(invalid)}. Valid options: {', '.join(VALID_CHOICES)}"
783+
error_msg = (
784+
f"Invalid choices: {', '.join(invalid)}. Valid options: {', '.join(valid_sources)}"
787785
)
786+
raise _argparse.ArgumentTypeError(error_msg)
788787
return items
789788

790-
def boolean_or_source_list(value):
789+
def boolean_or_source_list(value: str) -> bool | list[str]:
791790
"""Parse input as boolean or a list of valid choices."""
792791
true_values = {"true", "yes", "1"}
793792
false_values = {"false", "no", "0"}
794793
if value.lower() in true_values:
795794
return True
796-
elif value.lower() in false_values:
795+
if value.lower() in false_values:
797796
return False
798797
return source_list(value)
799798

799+
valid_sources = ["conda", "pip", "apt", "brew", "choco", "winget", "bash", "pwsh"]
800800
parser = _argparse.ArgumentParser(description="Install package and/or test-suite dependencies.")
801801
parser.add_argument("--filepath", type=str, default=".github/.repodynamics/metadata.json")
802802
parser.add_argument(
@@ -821,7 +821,7 @@ def boolean_or_source_list(value):
821821
parser.add_argument(
822822
"--sources",
823823
nargs="*",
824-
choices=["conda", "pip", "apt", "brew", "choco", "winget", "bash", "pwsh"],
824+
choices=valid_sources,
825825
default=None,
826826
)
827827
parser.add_argument(
@@ -837,14 +837,14 @@ def boolean_or_source_list(value):
837837
"--install",
838838
type=boolean_or_source_list,
839839
default=True,
840-
help="Boolean (true/false) or a list of package managers (comma-separated): conda, pip, apt, brew, choco, winget, bash, pwsh"
840+
help="Boolean (true/false) or a list of package managers (comma-separated): conda, pip, apt, brew, choco, winget, bash, pwsh",
841841
)
842842
parser.add_argument(
843843
"--exclude-install",
844844
nargs="*",
845845
choices=["conda", "pip", "apt", "brew", "choco", "winget", "bash", "pwsh"],
846846
default=None,
847-
help="List of package managers to exclude from installation: conda, pip, apt, brew, choco, winget, bash, pwsh"
847+
help="List of package managers to exclude from installation: conda, pip, apt, brew, choco, winget, bash, pwsh",
848848
)
849849
parser.add_argument("--output-dir", type=str, default=None)
850850
parser.add_argument("--overwrite", action=_argparse.BooleanOptionalAction, default=False)

0 commit comments

Comments
 (0)