diff --git a/python/deptry/cli.py b/python/deptry/cli.py index 8b483c83..afcff6b0 100644 --- a/python/deptry/cli.py +++ b/python/deptry/cli.py @@ -11,10 +11,6 @@ from deptry.config import read_configuration_from_pyproject_toml from deptry.core import Core -from deptry.deprecate.requirements_txt import ( - REQUIREMENTS_TXT_DEPRECATION_MESSAGE, - REQUIREMENTS_TXT_DEV_DEPRECATION_MESSAGE, -) if TYPE_CHECKING: from collections.abc import Mapping, MutableMapping, Sequence @@ -187,18 +183,12 @@ def display_deptry_version(ctx: click.Context, _param: click.Parameter, value: b callback=display_deptry_version, help="Display the current version and exit.", ) -@click.option( - "--requirements-txt", "-rt", type=COMMA_SEPARATED_TUPLE, help="To be deprecated.", hidden=True, default=() -) -@click.option( - "--requirements-txt-dev", "-rtd", type=COMMA_SEPARATED_TUPLE, help="To be deprecated.", hidden=True, default=() -) @click.option( "--requirements-files", "-rf", type=COMMA_SEPARATED_TUPLE, help=f""".txt files to scan for dependencies. If a file called pyproject.toml with a [tool.poetry.dependencies] or [project] section is found, this argument is ignored - and the dependencies are extracted from the pyproject.toml file instead. Can be multiple e.g. `deptry . --requirements-txt req/prod.txt,req/extra.txt` + and the dependencies are extracted from the pyproject.toml file instead. Can be multiple e.g. `deptry . --requirements-files req/prod.txt,req/extra.txt` [default: {", ".join(DEFAULT_REQUIREMENTS_FILES)}]""", ) @click.option( @@ -206,7 +196,7 @@ def display_deptry_version(ctx: click.Context, _param: click.Parameter, value: b "-rfd", type=COMMA_SEPARATED_TUPLE, help=""".txt files to scan for additional development dependencies. If a file called pyproject.toml with a [tool.poetry.dependencies] or [project] section is found, this argument is ignored - and the dependencies are extracted from the pyproject.toml file instead. Can be multiple e.g. `deptry . --requirements-txt-dev req/dev.txt,req/test.txt`""", + and the dependencies are extracted from the pyproject.toml file instead. Can be multiple e.g. `deptry . --requirements-files-dev req/dev.txt,req/test.txt`""", default=("dev-requirements.txt", "requirements-dev.txt"), show_default=True, ) @@ -259,8 +249,6 @@ def deptry( exclude: tuple[str, ...], extend_exclude: tuple[str, ...], ignore_notebooks: bool, - requirements_txt: tuple[str, ...], - requirements_txt_dev: tuple[str, ...], requirements_files: tuple[str, ...], requirements_files_dev: tuple[str, ...], known_first_party: tuple[str, ...], @@ -283,12 +271,6 @@ def deptry( """ - if requirements_txt: - logging.warning(REQUIREMENTS_TXT_DEPRECATION_MESSAGE) - - if requirements_txt_dev: - logging.warning(REQUIREMENTS_TXT_DEV_DEPRECATION_MESSAGE) - Core( root=root, config=config, @@ -299,9 +281,9 @@ def deptry( ignore_notebooks=ignore_notebooks, ignore=ignore, per_rule_ignores=per_rule_ignores, - requirements_files=(requirements_txt or requirements_files) or DEFAULT_REQUIREMENTS_FILES, - using_default_requirements_files=not (requirements_txt or requirements_files), - requirements_files_dev=requirements_txt_dev or requirements_files_dev, + requirements_files=requirements_files or DEFAULT_REQUIREMENTS_FILES, + using_default_requirements_files=not requirements_files, + requirements_files_dev=requirements_files_dev, known_first_party=known_first_party, json_output=json_output, package_module_name_map=package_module_name_map, diff --git a/python/deptry/deprecate/__init__.py b/python/deptry/deprecate/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/python/deptry/deprecate/requirements_txt.py b/python/deptry/deprecate/requirements_txt.py deleted file mode 100644 index 2a4c69cc..00000000 --- a/python/deptry/deprecate/requirements_txt.py +++ /dev/null @@ -1,15 +0,0 @@ -from __future__ import annotations - -REQUIREMENTS_TXT_DEPRECATION_MESSAGE = ( - "Warning: In an upcoming release, support for the `--requirements-txt` command-line " - "option and the `requirements_txt` configuration parameter will be discontinued. " - "Instead, use `--requirements-files` or `requirements_files` under the `[tool.deptry]` " - "section in pyproject.toml." -) - -REQUIREMENTS_TXT_DEV_DEPRECATION_MESSAGE = ( - "Warning: In an upcoming release, support for the `--requirements-txt-dev` command-line " - "option and the `requirements_txt_dev` configuration parameter will be discontinued. " - "Instead, use `--requirements-files-dev` or `requirements_files_dev` under the `[tool.deptry]` " - "section in pyproject.toml." -) diff --git a/tests/unit/deprecate/__init__.py b/tests/unit/deprecate/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/unit/deprecate/test_requirements_txt.py b/tests/unit/deprecate/test_requirements_txt.py deleted file mode 100644 index 51c61de6..00000000 --- a/tests/unit/deprecate/test_requirements_txt.py +++ /dev/null @@ -1,85 +0,0 @@ -from __future__ import annotations - -from unittest.mock import ANY, patch - -from click.testing import CliRunner - -from deptry.cli import deptry -from deptry.deprecate.requirements_txt import ( - REQUIREMENTS_TXT_DEPRECATION_MESSAGE, - REQUIREMENTS_TXT_DEV_DEPRECATION_MESSAGE, -) - -DEFAULT_CORE_ARGS = { - "root": (ANY,), - "config": ANY, - "no_ansi": ANY, - "exclude": ANY, - "extend_exclude": ANY, - "using_default_exclude": ANY, - "ignore_notebooks": ANY, - "ignore": ANY, - "per_rule_ignores": ANY, - "known_first_party": ANY, - "json_output": ANY, - "package_module_name_map": ANY, - "pep621_dev_dependency_groups": ANY, - "using_default_requirements_files": ANY, - "experimental_namespace_package": ANY, -} - - -def test_requirements_txt_deprecated() -> None: - with patch("deptry.cli.Core") as mock_core, patch("logging.warning") as mock_warning: - result = CliRunner().invoke(deptry, [".", "--requirements-txt", "somefile.txt"]) - - assert result.exit_code == 0 - mock_warning.assert_called_once_with(REQUIREMENTS_TXT_DEPRECATION_MESSAGE) - - # Assert that Core was instantiated with the correct arguments - mock_core.assert_called_once_with( - **DEFAULT_CORE_ARGS, - requirements_files=("somefile.txt",), - requirements_files_dev=("dev-requirements.txt", "requirements-dev.txt"), - ) - - -def test_requirements_txt_dev_deprecated() -> None: - with patch("deptry.cli.Core") as mock_core, patch("logging.warning") as mock_warning: - result = CliRunner().invoke(deptry, [".", "--requirements-txt-dev", "somefile.txt"]) - - assert result.exit_code == 0 - mock_warning.assert_called_once_with(REQUIREMENTS_TXT_DEV_DEPRECATION_MESSAGE) - - # Assert that Core was instantiated with the correct arguments - mock_core.assert_called_once_with( - **DEFAULT_CORE_ARGS, requirements_files=("requirements.txt",), requirements_files_dev=("somefile.txt",) - ) - - -def test_requirements_files_works_as_expected() -> None: - with patch("deptry.cli.Core") as mock_core, patch("logging.warning") as mock_warning: - result = CliRunner().invoke(deptry, [".", "--requirements-files", "somefile.txt"]) - - assert result.exit_code == 0 - mock_warning.assert_not_called() - - # Assert that Core was instantiated with the correct arguments - mock_core.assert_called_once_with( - **DEFAULT_CORE_ARGS, - requirements_files=("somefile.txt",), - requirements_files_dev=("dev-requirements.txt", "requirements-dev.txt"), - ) - - -def test_requirements_files_dev_works_as_expected() -> None: - with patch("deptry.cli.Core") as mock_core, patch("logging.warning") as mock_warning: - result = CliRunner().invoke(deptry, [".", "--requirements-files-dev", "somefile.txt"]) - - assert result.exit_code == 0 - mock_warning.assert_not_called() - - # Assert that Core was instantiated with the correct arguments - mock_core.assert_called_once_with( - **DEFAULT_CORE_ARGS, requirements_files=("requirements.txt",), requirements_files_dev=("somefile.txt",) - )