Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set the --parallel default to "auto", not CPU count #3109

Merged
merged 1 commit into from
Aug 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/tox/session/cmd/run/parallel.py
Expand Up @@ -19,15 +19,15 @@

ENV_VAR_KEY = "TOX_PARALLEL_ENV"
OFF_VALUE = 0
DEFAULT_PARALLEL = OFF_VALUE
DEFAULT_PARALLEL = "auto"


@impl
def tox_add_option(parser: ToxParser) -> None:
our = parser.add_command("run-parallel", ["p"], "run environments in parallel", run_parallel)
register_env_select_flags(our, default=CliEnv())
env_run_create_flags(our, mode="run-parallel")
parallel_flags(our, default_parallel=auto_detect_cpus())
parallel_flags(our, default_parallel=DEFAULT_PARALLEL)


def parse_num_processes(str_value: str) -> int | None:
Expand All @@ -46,7 +46,11 @@ def parse_num_processes(str_value: str) -> int | None:
return value


def parallel_flags(our: ArgumentParser, default_parallel: int, no_args: bool = False) -> None: # noqa: FBT001, FBT002
def parallel_flags(
our: ArgumentParser,
default_parallel: int | str,
no_args: bool = False, # noqa: FBT001, FBT002
) -> None:
our.add_argument(
"-p",
"--parallel",
Expand Down