diff --git a/README.rst b/README.rst index 9c4e11cff..eac48de6c 100644 --- a/README.rst +++ b/README.rst @@ -472,6 +472,11 @@ This section lists ``pip-tools`` features that are currently deprecated. - ``--index/--no-index`` command-line options, use instead ``--emit-index-url/--no-emit-index-url`` (since 5.2.0). +- In future versions, the ``--allow-unsafe`` behavior will be enabled by + default. Use ``--no-allow-unsafe`` to keep the old behavior. It is + recommended to pass the ``--allow-unsafe`` now to adapt to the upcoming + change. + Versions and compatibility ========================== diff --git a/piptools/scripts/compile.py b/piptools/scripts/compile.py index e8d6b96a3..ca650e491 100755 --- a/piptools/scripts/compile.py +++ b/piptools/scripts/compile.py @@ -164,11 +164,16 @@ def has_arg(self, arg_name): ), ) @click.option( - "--allow-unsafe", + "--allow-unsafe/--no-allow-unsafe", is_flag=True, default=False, - help="Pin packages considered unsafe: {}".format( - ", ".join(sorted(UNSAFE_PACKAGES)) + help=( + "Pin packages considered unsafe: {}.\n\n" + "WARNING: Future versions of pip-tools will enable this behavior by default. " + "Use --no-allow-unsafe to keep the old behavior. It is recommended to pass the " + "--allow-unsafe now to adapt to the upcoming change.".format( + ", ".join(sorted(UNSAFE_PACKAGES)) + ) ), ) @click.option( diff --git a/tests/test_cli_compile.py b/tests/test_cli_compile.py index b48263bca..993bfe4ee 100644 --- a/tests/test_cli_compile.py +++ b/tests/test_cli_compile.py @@ -1010,7 +1010,11 @@ def test_annotate_option(pip_conf, runner, option, expected): @pytest.mark.parametrize( ("option", "expected"), - (("--allow-unsafe", "small-fake-a==0.1"), (None, "# small-fake-a")), + ( + ("--allow-unsafe", "small-fake-a==0.1"), + ("--no-allow-unsafe", "# small-fake-a"), + (None, "# small-fake-a"), + ), ) def test_allow_unsafe_option(pip_conf, monkeypatch, runner, option, expected): """ diff --git a/tests/test_utils.py b/tests/test_utils.py index d9400450a..0332da911 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -260,6 +260,7 @@ def test_force_text(value, expected_text): (["--no-emit-index-url"], "pip-compile --no-emit-index-url"), (["--no-emit-trusted-host"], "pip-compile --no-emit-trusted-host"), (["--no-annotate"], "pip-compile --no-annotate"), + (["--no-allow-unsafe"], "pip-compile"), # Check that default values will be removed from the command (["--emit-trusted-host"], "pip-compile"), (["--annotate"], "pip-compile"),