Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove deprecated cli options and methods, revoke deprecation of --dev #9732

Merged
merged 2 commits into from
Oct 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 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,7 @@ 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)
* `--dev (-D)`: Add package as development dependency. (shortcut for `-G dev`)
* `--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 +481,7 @@ 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)
* `--dev (-D)`: Removes a package from the development dependencies. (shortcut for `-G dev`)
* `--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 +518,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 @@ -807,7 +800,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
7 changes: 1 addition & 6 deletions src/poetry/console/commands/add.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ class AddCommand(InstallerCommand, InitCommand):
option(
"dev",
"D",
"Add as a development dependency. (<warning>Deprecated</warning>) Use"
" --group=dev instead.",
"Add as a development dependency. (shortcut for '-G dev')",
),
option("editable", "e", "Add vcs/path dependencies as editable."),
option(
Expand Down Expand Up @@ -129,10 +128,6 @@ def handle(self) -> int:

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)
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()
7 changes: 1 addition & 6 deletions src/poetry/console/commands/remove.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ class RemoveCommand(InstallerCommand):
"dev",
"D",
"Remove a package from the development dependencies."
" (<warning>Deprecated</warning>)"
" Use --group=dev instead.",
" (shortcut for '-G dev')",
),
option(
"dry-run",
Expand All @@ -58,10 +57,6 @@ 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)
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()
10 changes: 2 additions & 8 deletions tests/console/commands/test_add.py
Original file line number Diff line number Diff line change
Expand Up @@ -1099,15 +1099,9 @@ 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:
def test_add_to_dev_section(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

Expand All @@ -1122,7 +1116,7 @@ def test_add_to_dev_section_deprecated(
Writing lock file
"""

assert tester.io.fetch_error() == warning
assert tester.io.fetch_error() == ""
assert tester.io.fetch_output() == expected
assert isinstance(tester.command, InstallerCommand)
assert tester.command.installer.executor.installations_count == 2
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
Loading