From 720e60fab2567df7a28ff5f15cfd7ac025195e3f Mon Sep 17 00:00:00 2001 From: finswimmer Date: Fri, 31 Jan 2025 22:01:15 +0100 Subject: [PATCH] docs: update docs about PEP 735 --- docs/managing-dependencies.md | 39 +++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/docs/managing-dependencies.md b/docs/managing-dependencies.md index 3e1c9f1d8bb..e1a2df35fab 100644 --- a/docs/managing-dependencies.md +++ b/docs/managing-dependencies.md @@ -27,14 +27,30 @@ are part of an implicit `main` group. Those dependencies are required by your pr Beside the `main` dependencies, you might have dependencies that are only needed to test your project or to build the documentation. -To declare a new dependency group, use a `tool.poetry.group.` section -where `` is the name of your dependency group (for instance, `test`): +To declare a new dependency group, use a `dependency-groups` section according to PEP 735 or +a `tool.poetry.group.` section where `` is the name of your dependency group (for instance, `test`): +{{< tabs tabTotal="2" tabID1="group-pep735" tabID2="group-poetry" tabName1="[dependency-groups]" tabName2="[tool.poetry]">}} + +{{< tab tabID="group-pep735" >}} +```toml +[dependency-groups] +test = [ + "pytest (>=6.0.0,<7.0.0)", + "pytest-mock", +] +``` +{{< /tab >}} + +{{< tab tabID="group-poetry" >}} ```toml [tool.poetry.group.test.dependencies] pytest = "^6.0.0" pytest-mock = "*" ``` +{{< /tab >}} +{{< /tabs >}} + {{% note %}} All dependencies **must be compatible with each other** across groups since they will @@ -60,6 +76,21 @@ A dependency group can be declared as optional. This makes sense when you have a group of dependencies that are only required in a particular environment or for a specific purpose. +{{< tabs tabTotal="2" tabID1="group-optional-pep735" tabID2="group-optional-poetry" tabName1="[dependency-groups]" tabName2="[tool.poetry]">}} + +{{< tab tabID="group-optional-pep735" >}} +```toml +[dependency-groups] +docs = [ + "mkdocs", +] + +[tool.poetry.group.docs] +optional = true +``` +{{< /tab >}} + +{{< tab tabID="group-optional-poetry" >}} ```toml [tool.poetry.group.docs] optional = true @@ -67,6 +98,10 @@ optional = true [tool.poetry.group.docs.dependencies] mkdocs = "*" ``` +{{< /tab >}} +{{< /tabs >}} + + Optional groups can be installed in addition to the **default** dependencies by using the `--with` option of the [`install`]({{< relref "cli#install" >}}) command.