From da352c28a15a2cfe68f767c0e95c15c5f68eb62f Mon Sep 17 00:00:00 2001 From: Don Naro Date: Wed, 28 Feb 2024 15:25:08 +0000 Subject: [PATCH] Update noxfile.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Sviatoslav Sydorenko (Святослав Сидоренко) --- noxfile.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/noxfile.py b/noxfile.py index c96e7a0e..e18243a6 100644 --- a/noxfile.py +++ b/noxfile.py @@ -7,17 +7,19 @@ def pip_compile(session: nox.Session): session.install("pip-tools >= 7") # Use --upgrade by default unless a user passes -P. - args = list(session.posargs) - if not any( - arg.startswith(("-P", "--upgrade-package", "--no-upgrade")) for arg in args - ): - args.append("--upgrade") + upgrade_related_cli_flags = "-P", "--upgrade-package", "--no-upgrade" + has_upgrade_related_cli_flags = any( + arg.startswith(upgrade_related_cli_flags) + for arg in session.posargs + ) + injected_extra_cli_args = () if has_upgrade_related_cli_flags else ("--upgrade",) session.run( "pip-compile", "--output-file", f"requirements.txt", - *args, + *session.posargs, + *injected_extra_cli_args, f"requirements.in", )