From 81f4c18365c57c70dfe0518e5f9273f4dc087a8d Mon Sep 17 00:00:00 2001 From: Frost Ming Date: Fri, 15 Dec 2023 10:07:20 +0800 Subject: [PATCH] feat: Rename `--no-lock` option to `--frozen-lockfile` Close #2493 Signed-off-by: Frost Ming --- news/2496.feature.md | 1 + src/pdm/cli/commands/add.py | 4 +-- src/pdm/cli/commands/install.py | 4 +-- src/pdm/cli/commands/remove.py | 11 ++++++-- src/pdm/cli/commands/update.py | 4 +-- src/pdm/cli/completions/pdm.bash | 8 +++--- src/pdm/cli/completions/pdm.fish | 8 +++--- src/pdm/cli/completions/pdm.ps1 | 8 +++--- src/pdm/cli/completions/pdm.zsh | 8 +++--- src/pdm/cli/options.py | 47 +++++++++++++++++++++++++++----- src/pdm/project/core.py | 5 +++- tests/cli/test_add.py | 2 +- tests/cli/test_install.py | 2 +- tests/cli/test_remove.py | 2 +- tests/cli/test_update.py | 2 +- 15 files changed, 80 insertions(+), 36 deletions(-) create mode 100644 news/2496.feature.md diff --git a/news/2496.feature.md b/news/2496.feature.md new file mode 100644 index 0000000000..fbe0d25b31 --- /dev/null +++ b/news/2496.feature.md @@ -0,0 +1 @@ +Rename `--no-lock` option to `--frozen-lockfile`. diff --git a/src/pdm/cli/commands/add.py b/src/pdm/cli/commands/add.py index 8780ed3227..0eb44b2210 100644 --- a/src/pdm/cli/commands/add.py +++ b/src/pdm/cli/commands/add.py @@ -8,9 +8,9 @@ from pdm.cli.hooks import HookManager from pdm.cli.options import ( dry_run_option, + frozen_lockfile_option, install_group, lockfile_option, - no_lock_option, packages_group, prerelease_option, save_strategy_group, @@ -34,7 +34,7 @@ class Command(BaseCommand): arguments = ( *BaseCommand.arguments, lockfile_option, - no_lock_option, + frozen_lockfile_option, save_strategy_group, update_strategy_group, prerelease_option, diff --git a/src/pdm/cli/commands/install.py b/src/pdm/cli/commands/install.py index aa1b8d1aa3..f2f9b6e9ca 100644 --- a/src/pdm/cli/commands/install.py +++ b/src/pdm/cli/commands/install.py @@ -8,10 +8,10 @@ from pdm.cli.hooks import HookManager from pdm.cli.options import ( dry_run_option, + frozen_lockfile_option, groups_group, install_group, lockfile_option, - no_lock_option, skip_option, venv_option, ) @@ -27,7 +27,7 @@ class Command(BaseCommand): install_group, dry_run_option, lockfile_option, - no_lock_option, + frozen_lockfile_option, skip_option, venv_option, ) diff --git a/src/pdm/cli/commands/remove.py b/src/pdm/cli/commands/remove.py index 463646589a..0cc097649a 100644 --- a/src/pdm/cli/commands/remove.py +++ b/src/pdm/cli/commands/remove.py @@ -6,7 +6,14 @@ from pdm.cli.commands.base import BaseCommand from pdm.cli.filters import GroupSelection from pdm.cli.hooks import HookManager -from pdm.cli.options import dry_run_option, install_group, lockfile_option, no_lock_option, skip_option, venv_option +from pdm.cli.options import ( + dry_run_option, + frozen_lockfile_option, + install_group, + lockfile_option, + skip_option, + venv_option, +) from pdm.exceptions import PdmUsageError, ProjectError if TYPE_CHECKING: @@ -23,7 +30,7 @@ class Command(BaseCommand): install_group, dry_run_option, lockfile_option, - no_lock_option, + frozen_lockfile_option, skip_option, venv_option, ) diff --git a/src/pdm/cli/commands/update.py b/src/pdm/cli/commands/update.py index 2e70f1de51..2b1bb44c04 100644 --- a/src/pdm/cli/commands/update.py +++ b/src/pdm/cli/commands/update.py @@ -8,10 +8,10 @@ from pdm.cli.filters import GroupSelection from pdm.cli.hooks import HookManager from pdm.cli.options import ( + frozen_lockfile_option, groups_group, install_group, lockfile_option, - no_lock_option, prerelease_option, save_strategy_group, skip_option, @@ -36,7 +36,7 @@ class Command(BaseCommand): groups_group, install_group, lockfile_option, - no_lock_option, + frozen_lockfile_option, save_strategy_group, update_strategy_group, prerelease_option, diff --git a/src/pdm/cli/completions/pdm.bash b/src/pdm/cli/completions/pdm.bash index 71b03a5501..e925f4e5a5 100644 --- a/src/pdm/cli/completions/pdm.bash +++ b/src/pdm/cli/completions/pdm.bash @@ -29,7 +29,7 @@ _pdm_a919b69078acdf0a_complete() case "$com" in (add) - opts="--dev --dry-run --editable --fail-fast --global --group --help --lockfile --no-editable --no-isolation --no-lock --no-self --no-sync --prerelease --project --quiet --save-compatible --save-exact --save-minimum --save-wildcard --skip --unconstrained --update-all --update-eager --update-reuse --update-reuse-installed --venv --verbose" + opts="--dev --dry-run --editable --fail-fast --frozen-lockfile --global --group --help --lockfile --no-editable --no-isolation --no-self --no-sync --prerelease --project --quiet --save-compatible --save-exact --save-minimum --save-wildcard --skip --unconstrained --update-all --update-eager --update-reuse --update-reuse-installed --venv --verbose" ;; (build) @@ -69,7 +69,7 @@ _pdm_a919b69078acdf0a_complete() ;; (install) - opts="--check --dev --dry-run --fail-fast --global --group --help --lockfile --no-default --no-editable --no-isolation --no-lock --no-self --plugins --production --project --quiet --skip --venv --verbose" + opts="--check --dev --dry-run --fail-fast --frozen-lockfile --global --group --help --lockfile --no-default --no-editable --no-isolation --no-self --plugins --production --project --quiet --skip --venv --verbose" ;; (list) @@ -89,7 +89,7 @@ _pdm_a919b69078acdf0a_complete() ;; (remove) - opts="--dev --dry-run --fail-fast --global --group --help --lockfile --no-editable --no-isolation --no-lock --no-self --no-sync --project --quiet --skip --venv --verbose" + opts="--dev --dry-run --fail-fast --frozen-lockfile --global --group --help --lockfile --no-editable --no-isolation --no-self --no-sync --project --quiet --skip --venv --verbose" ;; (run) @@ -113,7 +113,7 @@ _pdm_a919b69078acdf0a_complete() ;; (update) - opts="--dev --fail-fast --global --group --help --lockfile --no-default --no-editable --no-isolation --no-lock --no-self --no-sync --outdated --prerelease --production --project --quiet --save-compatible --save-exact --save-minimum --save-wildcard --skip --top --unconstrained --update-all --update-eager --update-reuse --update-reuse-installed --venv --verbose" + opts="--dev --fail-fast --frozen-lockfile --global --group --help --lockfile --no-default --no-editable --no-isolation --no-self --no-sync --outdated --prerelease --production --project --quiet --save-compatible --save-exact --save-minimum --save-wildcard --skip --top --unconstrained --update-all --update-eager --update-reuse --update-reuse-installed --venv --verbose" ;; (use) diff --git a/src/pdm/cli/completions/pdm.fish b/src/pdm/cli/completions/pdm.fish index d72f2d36c5..b170ea3d20 100644 --- a/src/pdm/cli/completions/pdm.fish +++ b/src/pdm/cli/completions/pdm.fish @@ -26,13 +26,13 @@ complete -c pdm -A -n '__fish_seen_subcommand_from add' -l dev -d 'Add packages complete -c pdm -A -n '__fish_seen_subcommand_from add' -l dry-run -d 'Show the difference only and don\'t perform any action' complete -c pdm -A -n '__fish_seen_subcommand_from add' -l editable -d 'Specify editable packages' complete -c pdm -A -n '__fish_seen_subcommand_from add' -l fail-fast -d 'Abort on first installation error' +complete -c pdm -A -n '__fish_seen_subcommand_from add' -l frozen-lockfile -d 'Don\'t try to create or update the lockfile. [env var: PDM_FROZEN_LOCKFILE]' complete -c pdm -A -n '__fish_seen_subcommand_from add' -l global -d 'Use the global project, supply the project root with `-p` option' complete -c pdm -A -n '__fish_seen_subcommand_from add' -l group -d 'Specify the target dependency group to add into' complete -c pdm -A -n '__fish_seen_subcommand_from add' -l help -d 'Show this help message and exit.' complete -c pdm -A -n '__fish_seen_subcommand_from add' -l lockfile -d 'Specify another lockfile path. Default: pdm.lock. [env var: PDM_LOCKFILE]' complete -c pdm -A -n '__fish_seen_subcommand_from add' -l no-editable -d 'Install non-editable versions for all packages' complete -c pdm -A -n '__fish_seen_subcommand_from add' -l no-isolation -d 'Disable isolation when building a source distribution that follows PEP 517, as in: build dependencies specified by PEP 518 must be already installed if this option is used.' -complete -c pdm -A -n '__fish_seen_subcommand_from add' -l no-lock -d 'Don\'t try to create or update the lockfile. [env var: PDM_NO_LOCK]' complete -c pdm -A -n '__fish_seen_subcommand_from add' -l no-self -d 'Don\'t install the project itself. [env var: PDM_NO_SELF]' complete -c pdm -A -n '__fish_seen_subcommand_from add' -l no-sync -d 'Only write pyproject.toml and do not sync the working set' complete -c pdm -A -n '__fish_seen_subcommand_from add' -l prerelease -d 'Allow prereleases to be pinned' @@ -187,6 +187,7 @@ complete -c pdm -A -n '__fish_seen_subcommand_from install' -l check -d 'Check i complete -c pdm -A -n '__fish_seen_subcommand_from install' -l dev -d 'Select dev dependencies' complete -c pdm -A -n '__fish_seen_subcommand_from install' -l dry-run -d 'Show the difference only and don\'t perform any action' complete -c pdm -A -n '__fish_seen_subcommand_from install' -l fail-fast -d 'Abort on first installation error' +complete -c pdm -A -n '__fish_seen_subcommand_from install' -l frozen-lockfile -d 'Don\'t try to create or update the lockfile. [env var: PDM_FROZEN_LOCKFILE]' complete -c pdm -A -n '__fish_seen_subcommand_from install' -l global -d 'Use the global project, supply the project root with `-p` option' complete -c pdm -A -n '__fish_seen_subcommand_from install' -l group -d 'Select group of optional-dependencies separated by comma or dev-dependencies (with `-d`). Can be supplied multiple times, use ":all" to include all groups under the same species.' complete -c pdm -A -n '__fish_seen_subcommand_from install' -l help -d 'Show this help message and exit.' @@ -194,7 +195,6 @@ complete -c pdm -A -n '__fish_seen_subcommand_from install' -l lockfile -d 'Spec complete -c pdm -A -n '__fish_seen_subcommand_from install' -l no-default -d 'Don\'t include dependencies from the default group' complete -c pdm -A -n '__fish_seen_subcommand_from install' -l no-editable -d 'Install non-editable versions for all packages' complete -c pdm -A -n '__fish_seen_subcommand_from install' -l no-isolation -d 'Disable isolation when building a source distribution that follows PEP 517, as in: build dependencies specified by PEP 518 must be already installed if this option is used.' -complete -c pdm -A -n '__fish_seen_subcommand_from install' -l no-lock -d 'Don\'t try to create or update the lockfile. [env var: PDM_NO_LOCK]' complete -c pdm -A -n '__fish_seen_subcommand_from install' -l no-self -d 'Don\'t install the project itself. [env var: PDM_NO_SELF]' complete -c pdm -A -n '__fish_seen_subcommand_from install' -l plugins -d 'Install the plugins specified in pyproject.toml' complete -c pdm -A -n '__fish_seen_subcommand_from install' -l production -d 'Unselect dev dependencies' @@ -308,13 +308,13 @@ complete -c pdm -f -n '__fish_pdm_a919b69078acdf0a_complete_no_subcommand' -a re complete -c pdm -A -n '__fish_seen_subcommand_from remove' -l dev -d 'Remove packages from dev dependencies' complete -c pdm -A -n '__fish_seen_subcommand_from remove' -l dry-run -d 'Show the difference only and don\'t perform any action' complete -c pdm -A -n '__fish_seen_subcommand_from remove' -l fail-fast -d 'Abort on first installation error' +complete -c pdm -A -n '__fish_seen_subcommand_from remove' -l frozen-lockfile -d 'Don\'t try to create or update the lockfile. [env var: PDM_FROZEN_LOCKFILE]' complete -c pdm -A -n '__fish_seen_subcommand_from remove' -l global -d 'Use the global project, supply the project root with `-p` option' complete -c pdm -A -n '__fish_seen_subcommand_from remove' -l group -d 'Specify the target dependency group to remove from' complete -c pdm -A -n '__fish_seen_subcommand_from remove' -l help -d 'Show this help message and exit.' complete -c pdm -A -n '__fish_seen_subcommand_from remove' -l lockfile -d 'Specify another lockfile path. Default: pdm.lock. [env var: PDM_LOCKFILE]' complete -c pdm -A -n '__fish_seen_subcommand_from remove' -l no-editable -d 'Install non-editable versions for all packages' complete -c pdm -A -n '__fish_seen_subcommand_from remove' -l no-isolation -d 'Disable isolation when building a source distribution that follows PEP 517, as in: build dependencies specified by PEP 518 must be already installed if this option is used.' -complete -c pdm -A -n '__fish_seen_subcommand_from remove' -l no-lock -d 'Don\'t try to create or update the lockfile. [env var: PDM_NO_LOCK]' complete -c pdm -A -n '__fish_seen_subcommand_from remove' -l no-self -d 'Don\'t install the project itself. [env var: PDM_NO_SELF]' complete -c pdm -A -n '__fish_seen_subcommand_from remove' -l no-sync -d 'Only write pyproject.toml and do not uninstall packages' complete -c pdm -A -n '__fish_seen_subcommand_from remove' -l project -d 'Specify another path as the project root, which changes the base of pyproject.toml and __pypackages__ [env var: PDM_PROJECT]' @@ -422,6 +422,7 @@ complete -c pdm -A -n '__fish_seen_subcommand_from sync' -l verbose -d 'Use `-v` complete -c pdm -f -n '__fish_pdm_a919b69078acdf0a_complete_no_subcommand' -a update -d 'Update package(s) in pyproject.toml' complete -c pdm -A -n '__fish_seen_subcommand_from update' -l dev -d 'Select dev dependencies' complete -c pdm -A -n '__fish_seen_subcommand_from update' -l fail-fast -d 'Abort on first installation error' +complete -c pdm -A -n '__fish_seen_subcommand_from update' -l frozen-lockfile -d 'Don\'t try to create or update the lockfile. [env var: PDM_FROZEN_LOCKFILE]' complete -c pdm -A -n '__fish_seen_subcommand_from update' -l global -d 'Use the global project, supply the project root with `-p` option' complete -c pdm -A -n '__fish_seen_subcommand_from update' -l group -d 'Select group of optional-dependencies separated by comma or dev-dependencies (with `-d`). Can be supplied multiple times, use ":all" to include all groups under the same species.' complete -c pdm -A -n '__fish_seen_subcommand_from update' -l help -d 'Show this help message and exit.' @@ -429,7 +430,6 @@ complete -c pdm -A -n '__fish_seen_subcommand_from update' -l lockfile -d 'Speci complete -c pdm -A -n '__fish_seen_subcommand_from update' -l no-default -d 'Don\'t include dependencies from the default group' complete -c pdm -A -n '__fish_seen_subcommand_from update' -l no-editable -d 'Install non-editable versions for all packages' complete -c pdm -A -n '__fish_seen_subcommand_from update' -l no-isolation -d 'Disable isolation when building a source distribution that follows PEP 517, as in: build dependencies specified by PEP 518 must be already installed if this option is used.' -complete -c pdm -A -n '__fish_seen_subcommand_from update' -l no-lock -d 'Don\'t try to create or update the lockfile. [env var: PDM_NO_LOCK]' complete -c pdm -A -n '__fish_seen_subcommand_from update' -l no-self -d 'Don\'t install the project itself. [env var: PDM_NO_SELF]' complete -c pdm -A -n '__fish_seen_subcommand_from update' -l no-sync -d 'Only update lock file but do not sync packages' complete -c pdm -A -n '__fish_seen_subcommand_from update' -l outdated -d 'Show the difference only without modifying the lockfile content' diff --git a/src/pdm/cli/completions/pdm.ps1 b/src/pdm/cli/completions/pdm.ps1 index d10e8479d9..ab6165026b 100644 --- a/src/pdm/cli/completions/pdm.ps1 +++ b/src/pdm/cli/completions/pdm.ps1 @@ -211,7 +211,7 @@ function TabExpansion($line, $lastWord) { "-d", "--dev", "--save-compatible", "--save-wildcard", "--dry-run", "--save-exact", "--save-minimum", "--update-eager", "--update-reuse", "--update-all", "-g", "--global", "--no-sync", "--no-editable", "--no-self", "-u", "--unconstrained", "--no-isolation", - "--pre", "--prerelease", "-L", "--lockfile", "--fail-fast", "-x", "--no-lock", "--update-reuse-installed" + "--pre", "--prerelease", "-L", "--lockfile", "--fail-fast", "-x", "--frozen-lockfile", "--update-reuse-installed" )), $sectionOption, $projectOption, @@ -298,7 +298,7 @@ function TabExpansion($line, $lastWord) { "install" { $completer.AddOpts(@( [Option]::new(( - "-d", "--dev", "-g", "--global", "--dry-run", "--no-default", "--no-lock", "--prod", + "-d", "--dev", "-g", "--global", "--dry-run", "--no-default", "--frozen-lockfile", "--prod", "--production", "--no-editable", "--no-self", "--no-isolation", "--check", "-L", "--lockfile", "--fail-fast", "-x", "--plugins" )), @@ -378,7 +378,7 @@ function TabExpansion($line, $lastWord) { @( [Option]::new(@( "--global", "-g", "--dev", "-d", "--dry-run", "--no-sync", "--no-editable", "--no-self", - "--no-isolation", "-L", "--lockfile", "--fail-fast", "-x", "--no-lock" + "--no-isolation", "-L", "--lockfile", "--fail-fast", "-x", "--frozen-lockfile" )), $projectOption, $skipOption, @@ -429,7 +429,7 @@ function TabExpansion($line, $lastWord) { "-d", "--dev", "--save-compatible", "--prod", "--production", "--save-wildcard", "--save-exact", "--save-minimum", "--update-eager", "--update-reuse", "--update-all", "-g", "--global", "--dry-run", "--outdated", "--top", "-u", "--unconstrained", "--no-editable", "--no-self", "--no-isolation", - "--no-sync", "--pre", "--prerelease", "-L", "--lockfile", "--fail-fast", "-x", "--no-lock", + "--no-sync", "--pre", "--prerelease", "-L", "--lockfile", "--fail-fast", "-x", "--frozen-lockfile", "--update-reuse-installed" )), $sectionOption, diff --git a/src/pdm/cli/completions/pdm.zsh b/src/pdm/cli/completions/pdm.zsh index 323fbe318c..dca802b853 100644 --- a/src/pdm/cli/completions/pdm.zsh +++ b/src/pdm/cli/completions/pdm.zsh @@ -75,7 +75,7 @@ _pdm() { '--update-all[Update all dependencies and sub-dependencies]' '--no-editable[Install non-editable versions for all packages]' "--no-self[Don't install the project itself]" - "--no-lock[Don't try to create or update the lockfile. [env var: PDM_NO_LOCK]]" + "--frozen-lockfile[Don't try to create or update the lockfile. [env var: PDM_FROZEN_LOCKFILE]]" '--venv[Run the command in the virtual environment with the given key. (env var: PDM_IN_VENV)]:venv:' {-k,--skip}'[Skip some tasks and/or hooks by their comma-separated names]' {-u,--unconstrained}'[Ignore the version constraint of packages]' @@ -207,7 +207,7 @@ _pdm() { {-L,--lockfile}'[Specify another lockfile path, or use `PDM_LOCKFILE` env variable. Default: pdm.lock]:lockfile:_files' {--prod,--production}"[Unselect dev dependencies]" {-k,--skip}'[Skip some tasks and/or hooks by their comma-separated names]' - "--no-lock[Don't try to create or update the lockfile. [env var: PDM_NO_LOCK]]" + "--frozen-lockfile[Don't try to create or update the lockfile. [env var: PDM_FROZEN_LOCKFILE]]" "--no-default[Don\'t include dependencies from the default group]" '--no-editable[Install non-editable versions for all packages]' "--no-self[Don't install the project itself]" @@ -331,7 +331,7 @@ _pdm() { "--no-sync[Only write pyproject.toml and do not uninstall packages]" '--no-editable[Install non-editable versions for all packages]' "--no-self[Don't install the project itself]" - "--no-lock[Don't try to create or update the lockfile. [env var: PDM_NO_LOCK]]" + "--frozen-lockfile[Don't try to create or update the lockfile. [env var: PDM_FROZEN_LOCKFILE]]" {-x,--fail-fast}'[Abort on first installation error]' "--no-isolation[do not isolate the build in a clean environment]" "--dry-run[Show the difference only without modifying the lockfile content]" @@ -410,7 +410,7 @@ _pdm() { '--no-editable[Install non-editable versions for all packages]' "--no-self[Don't install the project itself]" "--no-sync[Only update lock file but do not sync packages]" - "--no-lock[Don't try to create or update the lockfile. [env var: PDM_NO_LOCK]]" + "--frozen-lockfile[Don't try to create or update the lockfile. [env var: PDM_FROZEN_LOCKFILE]]" {-k,--skip}'[Skip some tasks and/or hooks by their comma-separated names]' {-u,--unconstrained}'[Ignore the version constraint of packages]' {--pre,--prerelease}'[Allow prereleases to be pinned]' diff --git a/src/pdm/cli/options.py b/src/pdm/cli/options.py index 2444d5bd94..c6f518a631 100644 --- a/src/pdm/cli/options.py +++ b/src/pdm/cli/options.py @@ -12,7 +12,13 @@ from pdm.project import Project class ActionCallback(Protocol): - def __call__(self, project: Project, namespace: argparse.Namespace, values: str | Sequence[Any] | None) -> None: + def __call__( + self, + project: Project, + namespace: argparse.Namespace, + values: str | Sequence[Any] | None, + option_string: str | None = None, + ) -> None: ... @@ -50,7 +56,7 @@ def __call__( ) -> None: if not hasattr(namespace, "callbacks"): namespace.callbacks = [] - callback = partial(self.callback, values=values) + callback = partial(self.callback, values=values, option_string=option_string) namespace.callbacks.append(callback) @@ -144,13 +150,30 @@ def from_splitted_env(name: str, separator: str) -> list[str] | None: ) -@Option("--no-lock", nargs=0, help="Don't try to create or update the lockfile. [env var: PDM_NO_LOCK]") -def no_lock_option(project: Project, namespace: argparse.Namespace, values: str | Sequence[Any] | None) -> None: +@Option( + "--frozen-lockfile", + "--no-lock", + nargs=0, + help="Don't try to create or update the lockfile. [env var: PDM_FROZEN_LOCKFILE]", +) +def frozen_lockfile_option( + project: Project, + namespace: argparse.Namespace, + values: str | Sequence[Any] | None, + option_string: str | None = None, +) -> None: + if option_string == "--no-lock": + project.core.ui.warn("--no-lock is deprecated, use --frozen-lockfile instead.") project.enable_write_lockfile = False @Option("--pep582", const="AUTO", metavar="SHELL", nargs="?", help="Print the command line to be eval'd by the shell") -def pep582_option(project: Project, namespace: argparse.Namespace, values: str | Sequence[Any] | None) -> None: +def pep582_option( + project: Project, + namespace: argparse.Namespace, + values: str | Sequence[Any] | None, + option_string: str | None = None, +) -> None: from pdm.cli.actions import print_pep582_command print_pep582_command(project, cast(str, values)) @@ -181,7 +204,12 @@ def pep582_option(project: Project, namespace: argparse.Namespace, values: str | help="Disable isolation when building a source distribution that follows PEP 517, " "as in: build dependencies specified by PEP 518 must be already installed if this option is used.", ) -def no_isolation_option(project: Project, namespace: argparse.Namespace, values: str | Sequence[Any] | None) -> None: +def no_isolation_option( + project: Project, + namespace: argparse.Namespace, + values: str | Sequence[Any] | None, + option_string: str | None = None, +) -> None: os.environ["PDM_BUILD_ISOLATION"] = "no" @@ -341,7 +369,12 @@ def no_isolation_option(project: Project, namespace: argparse.Namespace, values: nargs=0, help="Ignore the Python path saved in .pdm-python. [env var: PDM_IGNORE_SAVED_PYTHON]", ) -def ignore_python_option(project: Project, namespace: argparse.Namespace, values: str | Sequence[Any] | None) -> None: +def ignore_python_option( + project: Project, + namespace: argparse.Namespace, + values: str | Sequence[Any] | None, + option_string: str | None = None, +) -> None: os.environ.update({"PDM_IGNORE_SAVED_PYTHON": "1"}) diff --git a/src/pdm/project/core.py b/src/pdm/project/core.py index ebb5a858d5..7e2e52224a 100644 --- a/src/pdm/project/core.py +++ b/src/pdm/project/core.py @@ -99,7 +99,10 @@ def __init__( self.root: Path = Path(root_path or "").absolute() self.is_global = is_global - self.enable_write_lockfile = os.getenv("PDM_NO_LOCK", "0").lower() not in ("1", "true") + self.enable_write_lockfile = os.getenv("PDM_FROZEN_LOCKFILE", os.getenv("PDM_NO_LOCK", "0")).lower() not in ( + "1", + "true", + ) self.init_global_project() def __repr__(self) -> str: diff --git a/tests/cli/test_add.py b/tests/cli/test_add.py index f133b1e459..2c865d1604 100644 --- a/tests/cli/test_add.py +++ b/tests/cli/test_add.py @@ -26,7 +26,7 @@ def test_add_package(project, working_set, dev_option, pdm): def test_add_package_no_lock(project, working_set, dev_option, pdm): - pdm(["add", *dev_option, "--no-lock", "-v", "requests"], obj=project, strict=True) + pdm(["add", *dev_option, "--frozen-lockfile", "-v", "requests"], obj=project, strict=True) group = ( project.pyproject.settings["dev-dependencies"]["dev"] if dev_option diff --git a/tests/cli/test_install.py b/tests/cli/test_install.py index 7fc0751ec8..c42b930aaa 100644 --- a/tests/cli/test_install.py +++ b/tests/cli/test_install.py @@ -170,7 +170,7 @@ def test_install_with_dry_run(project, pdm, repository): def test_install_no_lock(project, pdm, working_set): project.add_dependencies({"requests": parse_requirement("requests")}, "default") - result = pdm(["install", "--no-lock"], obj=project) + result = pdm(["install", "--frozen-lockfile"], obj=project) assert result.exit_code == 0 assert not project.lockfile.exists() assert "urllib3" in working_set diff --git a/tests/cli/test_remove.py b/tests/cli/test_remove.py index d34190e063..99ca22d44b 100644 --- a/tests/cli/test_remove.py +++ b/tests/cli/test_remove.py @@ -34,7 +34,7 @@ def test_remove_package(project, working_set, dev_option, pdm): def test_remove_package_no_lock(project, working_set, dev_option, pdm): pdm(["add", *dev_option, "requests", "pytz"], obj=project, strict=True) - pdm(["remove", *dev_option, "--no-lock", "pytz"], obj=project, strict=True) + pdm(["remove", *dev_option, "--frozen-lockfile", "pytz"], obj=project, strict=True) assert "pytz" not in working_set project.lockfile.reload() locked_candidates = project.locked_repository.all_candidates diff --git a/tests/cli/test_update.py b/tests/cli/test_update.py index 892916ae28..e2ae72d7ec 100644 --- a/tests/cli/test_update.py +++ b/tests/cli/test_update.py @@ -64,7 +64,7 @@ def test_update_all_packages(project, repository, pdm, strategy): def test_update_no_lock(project, working_set, repository, pdm): pdm(["add", "pytz"], obj=project, strict=True) repository.add_candidate("pytz", "2019.6") - pdm(["update", "--no-lock"], obj=project, strict=True) + pdm(["update", "--frozen-lockfile"], obj=project, strict=True) assert working_set["pytz"].version == "2019.6" project.lockfile.reload() assert project.locked_repository.all_candidates["pytz"].version == "2019.3"