Skip to content

Commit

Permalink
remove deprecated cli options and methods
Browse files Browse the repository at this point in the history
  • Loading branch information
radoering committed Oct 5, 2024
1 parent 739cbb8 commit 26ad7fa
Show file tree
Hide file tree
Showing 16 changed files with 2 additions and 257 deletions.
10 changes: 0 additions & 10 deletions docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,6 @@ the `--without` option.
poetry install --without test,docs
```

{{% note %}}
The `--no-dev` option is now deprecated. You should use the `--only main` or `--without dev` notation instead.
{{% /note %}}

You can also select optional dependency groups with the `--with` option.

```bash
Expand Down Expand Up @@ -262,7 +258,6 @@ poetry install --compile
* `--extras (-E)`: Features to install (multiple values allowed).
* `--all-extras`: Install all extra features (conflicts with --extras).
* `--compile`: Compile Python source files to bytecode.
* `--no-dev`: Do not install dev dependencies. (**Deprecated**, use `--only main` or `--without dev` instead)
* `--remove-untracked`: Remove dependencies not presented in the lock file. (**Deprecated**, use `--sync` instead)

{{% note %}}
Expand Down Expand Up @@ -301,7 +296,6 @@ You can do this using the `add` command.
* `--with`: The optional dependency groups to include.
* `--only`: The only dependency groups to include.
* `--dry-run` : Outputs the operations but will not execute anything (implicitly enables --verbose).
* `--no-dev` : Do not update the development dependencies. (**Deprecated**, use `--only main` or `--without dev` instead)
* `--lock` : Do not perform install (only update the lockfile).
* `--sync`: Synchronize the environment with the locked packages and the specified groups.

Expand Down Expand Up @@ -454,7 +448,6 @@ about dependency groups.
### Options

* `--group (-G)`: The group to add the dependency to.
* `--dev (-D)`: Add package as development dependency. (**Deprecated**, use `-G dev` instead)
* `--editable (-e)`: Add vcs/path dependencies as editable.
* `--extras (-E)`: Extras to activate for the dependency. (multiple values allowed)
* `--optional`: Add as an optional dependency to an extra.
Expand Down Expand Up @@ -487,7 +480,6 @@ about dependency groups.
### Options

* `--group (-G)`: The group to remove the dependency from.
* `--dev (-D)`: Removes a package from the development dependencies. (**Deprecated**, use `-G dev` instead)
* `--dry-run` : Outputs the operations but will not execute anything (implicitly enables --verbose).
* `--lock`: Do not perform operations (only update the lockfile).

Expand Down Expand Up @@ -524,7 +516,6 @@ required by
* `--why`: When showing the full list, or a `--tree` for a single package, display whether they are a direct dependency or required by other packages.
* `--with`: The optional dependency groups to include.
* `--only`: The only dependency groups to include.
* `--no-dev`: Do not list the dev dependencies. (**Deprecated**, use `--only main` or `--without dev` instead)
* `--tree`: List the dependencies as a tree.
* `--latest (-l)`: Show the latest version.
* `--outdated (-o)`: Show the latest version but only for packages that are outdated.
Expand Down Expand Up @@ -801,7 +792,6 @@ group defined in `tool.poetry.dependencies` when used without specifying any opt
Currently, only `constraints.txt` and `requirements.txt` are supported.
* `--output (-o)`: The name of the output file. If omitted, print to standard
output.
* `--dev`: Include development dependencies. (**Deprecated**, use `--with dev` instead)
* `--extras (-E)`: Extra sets of dependencies to include.
* `--without`: The dependency groups to ignore.
* `--with`: The optional dependency groups to include.
Expand Down
15 changes: 1 addition & 14 deletions src/poetry/console/commands/add.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ class AddCommand(InstallerCommand, InitCommand):
flag=False,
default=MAIN_GROUP,
),
option(
"dev",
"D",
"Add as a development dependency. (<warning>Deprecated</warning>) Use"
" --group=dev instead.",
),
option("editable", "e", "Add vcs/path dependencies as editable."),
option(
"extras",
Expand Down Expand Up @@ -128,14 +122,7 @@ def handle(self) -> int:
from poetry.factory import Factory

packages = self.argument("name")
if self.option("dev"):
self.line_error(
"<warning>The --dev option is deprecated, "
"use the `--group dev` notation instead.</warning>"
)
group = "dev"
else:
group = self.option("group", self.default_group or MAIN_GROUP)
group = self.option("group", self.default_group or MAIN_GROUP)

if self.option("extras") and len(packages) > 1:
raise ValueError(
Expand Down
13 changes: 0 additions & 13 deletions src/poetry/console/commands/group_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from typing import TYPE_CHECKING

from cleo.helpers import option
from poetry.core.packages.dependency_group import MAIN_GROUP

from poetry.console.commands.command import Command
from poetry.console.exceptions import GroupNotFoundError
Expand Down Expand Up @@ -82,18 +81,6 @@ def activated_groups(self) -> set[str]:
}
self._validate_group_options(groups)

for opt, new, group in [
("no-dev", "only", MAIN_GROUP),
("dev", "with", "dev"),
]:
if self.io.input.has_option(opt) and self.option(opt):
self.line_error(
f"<warning>The `<fg=yellow;options=bold>--{opt}</>` option is"
f" deprecated, use the `<fg=yellow;options=bold>--{new} {group}</>`"
" notation instead.</warning>"
)
groups[new].add(group)

if groups["only"] and (groups["with"] or groups["without"]):
self.line_error(
"<warning>The `<fg=yellow;options=bold>--with</>` and "
Expand Down
20 changes: 0 additions & 20 deletions src/poetry/console/commands/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@ class InstallCommand(InstallerCommand):

options: ClassVar[list[Option]] = [
*InstallerCommand._group_dependency_options(),
option(
"no-dev",
None,
"Do not install the development dependencies."
" (<warning>Deprecated</warning>)",
),
option(
"sync",
None,
Expand All @@ -48,12 +42,6 @@ class InstallCommand(InstallerCommand):
"Output the operations but do not execute anything "
"(implicitly enables --verbose).",
),
option(
"remove-untracked",
None,
"Removes packages not present in the lock file."
" (<warning>Deprecated</warning>)",
),
option(
"extras",
"E",
Expand Down Expand Up @@ -145,14 +133,6 @@ def handle(self) -> int:
self.installer.extras(extras)

with_synchronization = self.option("sync")
if self.option("remove-untracked"):
self.line_error(
"<warning>The `<fg=yellow;options=bold>--remove-untracked</>` option is"
" deprecated, use the `<fg=yellow;options=bold>--sync</>` option"
" instead.</warning>"
)

with_synchronization = True

self.installer.only_groups(self.activated_groups)
self.installer.skip_directory(self.option("no-directory"))
Expand Down
23 changes: 0 additions & 23 deletions src/poetry/console/commands/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,6 @@ class LockCommand(InstallerCommand):
"Ignore existing lock file"
" and overwrite it with a new lock file created from scratch.",
),
option(
"check",
None,
"Check that the <comment>poetry.lock</> file corresponds to the current"
" version of <comment>pyproject.toml</>. (<warning>Deprecated</>) Use"
" <comment>poetry check --lock</> instead.",
),
]

help = """
Expand All @@ -46,22 +39,6 @@ class LockCommand(InstallerCommand):
loggers: ClassVar[list[str]] = ["poetry.repositories.pypi_repository"]

def handle(self) -> int:
if self.option("check"):
self.line_error(
"<warning>poetry lock --check is deprecated, use `poetry"
" check --lock` instead.</warning>"
)
if self.poetry.locker.is_locked() and self.poetry.locker.is_fresh():
self.line("poetry.lock is consistent with pyproject.toml.")
return 0
self.line_error(
"<error>"
"Error: pyproject.toml changed significantly since poetry.lock was last generated. "
"Run `poetry lock [--no-update]` to fix the lock file."
"</error>"
)
return 1

self.installer.lock(update=self.option("regenerate"))

return self.installer.run()
17 changes: 1 addition & 16 deletions src/poetry/console/commands/remove.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,6 @@ class RemoveCommand(InstallerCommand):
]
options: ClassVar[list[Option]] = [
option("group", "G", "The group to remove the dependency from.", flag=False),
option(
"dev",
"D",
"Remove a package from the development dependencies."
" (<warning>Deprecated</warning>)"
" Use --group=dev instead.",
),
option(
"dry-run",
None,
Expand All @@ -56,15 +49,7 @@ class RemoveCommand(InstallerCommand):

def handle(self) -> int:
packages = self.argument("packages")

if self.option("dev"):
self.line_error(
"<warning>The --dev option is deprecated, "
"use the `--group dev` notation instead.</warning>"
)
group = "dev"
else:
group = self.option("group", self.default_group)
group = self.option("group", self.default_group)

content: dict[str, Any] = self.poetry.file.read()
project_content = content.get("project", {})
Expand Down
5 changes: 0 additions & 5 deletions src/poetry/console/commands/show.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@ class ShowCommand(GroupCommand, EnvCommand):
]
options: ClassVar[list[Option]] = [
*GroupCommand._group_dependency_options(),
option(
"no-dev",
None,
"Do not list the development dependencies. (<warning>Deprecated</warning>)",
),
option("tree", "t", "List the dependencies as a tree."),
option(
"why",
Expand Down
6 changes: 0 additions & 6 deletions src/poetry/console/commands/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@ class UpdateCommand(InstallerCommand):
]
options: ClassVar[list[Option]] = [
*InstallerCommand._group_dependency_options(),
option(
"no-dev",
None,
"Do not update the development dependencies."
" (<warning>Deprecated</warning>)",
),
option(
"sync",
None,
Expand Down
13 changes: 0 additions & 13 deletions src/poetry/repositories/repository_pool.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import annotations

import enum
import warnings

from collections import OrderedDict
from dataclasses import dataclass
Expand All @@ -20,8 +19,6 @@
from poetry.core.packages.dependency import Dependency
from poetry.core.packages.package import Package

_SENTINEL = object()


class Priority(IntEnum):
# The order of the members below dictates the actual priority. The first member has
Expand All @@ -41,7 +38,6 @@ class RepositoryPool(AbstractRepository):
def __init__(
self,
repositories: list[Repository] | None = None,
ignore_repository_names: object = _SENTINEL,
*,
config: Config | None = None,
) -> None:
Expand All @@ -57,15 +53,6 @@ def __init__(
cache_dir=(config or Config.create()).artifacts_cache_directory
)

if ignore_repository_names is not _SENTINEL:
warnings.warn(
"The 'ignore_repository_names' argument to 'RepositoryPool.__init__' is"
" deprecated. It has no effect anymore and will be removed in a future"
" version.",
DeprecationWarning,
stacklevel=2,
)

@staticmethod
def from_packages(packages: list[Package], config: Config | None) -> RepositoryPool:
pool = RepositoryPool(config=config)
Expand Down
13 changes: 0 additions & 13 deletions src/poetry/toml/file.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
from __future__ import annotations

import warnings

from typing import TYPE_CHECKING
from typing import Any

from tomlkit.toml_file import TOMLFile as BaseTOMLFile

Expand Down Expand Up @@ -36,15 +33,5 @@ def read(self) -> TOMLDocument:
except (ValueError, TOMLKitError) as e:
raise TOMLError(f"Invalid TOML file {self.path.as_posix()}: {e}")

def __getattr__(self, item: str) -> Any:
warnings.warn(
"`__getattr__` will be removed from the `TOMLFile` in a future release."
"\n\nInstead of accessing properties of the underlying `Path` as "
"`tomlfile.whatever`, prefer `tomlfile.path.whatever`.",
DeprecationWarning,
stacklevel=2,
)
return getattr(self.__path, item)

def __str__(self) -> str:
return self.__path.as_posix()
35 changes: 0 additions & 35 deletions tests/console/commands/test_add.py
Original file line number Diff line number Diff line change
Expand Up @@ -1091,41 +1091,6 @@ def test_add_creating_poetry_section_does_not_remove_existing_tools(
assert pyproject["tool"]["foo"]["key"] == "value"


def test_add_to_dev_section_deprecated(
app: PoetryTestApplication, tester: CommandTester
) -> None:
tester.execute("cachy --dev")

warning = """\
The --dev option is deprecated, use the `--group dev` notation instead.
"""

expected = """\
Using version ^0.2.0 for cachy
Updating dependencies
Resolving dependencies...
Package operations: 2 installs, 0 updates, 0 removals
- Installing msgpack-python (0.5.6)
- Installing cachy (0.2.0)
Writing lock file
"""

assert tester.io.fetch_error() == warning
assert tester.io.fetch_output() == expected
assert isinstance(tester.command, InstallerCommand)
assert tester.command.installer.executor.installations_count == 2

pyproject: dict[str, Any] = app.poetry.file.read()
content = pyproject["tool"]["poetry"]

assert "cachy" in content["group"]["dev"]["dependencies"]
assert content["group"]["dev"]["dependencies"]["cachy"] == "^0.2.0"


def test_add_should_not_select_prereleases(
app: PoetryTestApplication, tester: CommandTester
) -> None:
Expand Down
18 changes: 0 additions & 18 deletions tests/console/commands/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,6 @@ def _project_factory(
("--without bam", {MAIN_GROUP, "foo", "bar", "baz", "bim"}),
("--with bam --without bam", {MAIN_GROUP, "foo", "bar", "baz", "bim"}),
("--with foo --without foo", {MAIN_GROUP, "bar", "baz", "bim"}),
# deprecated options
("--no-dev", {MAIN_GROUP}),
],
)
@pytest.mark.parametrize("with_root", [True, False])
Expand Down Expand Up @@ -350,22 +348,6 @@ def test_invalid_groups_with_without_only(
)


def test_remove_untracked_outputs_deprecation_warning(
tester: CommandTester,
mocker: MockerFixture,
) -> None:
assert isinstance(tester.command, InstallerCommand)
mocker.patch.object(tester.command.installer, "run", return_value=0)

tester.execute("--remove-untracked")

assert tester.status_code == 1
assert (
"The `--remove-untracked` option is deprecated, use the `--sync` option"
" instead.\n" in tester.io.fetch_error()
)


def test_dry_run_populates_installer(
tester: CommandTester, mocker: MockerFixture
) -> None:
Expand Down
Loading

0 comments on commit 26ad7fa

Please sign in to comment.