diff --git a/docs/supported-dependency-managers.md b/docs/supported-dependency-managers.md index f1037d93..e6d3efe4 100644 --- a/docs/supported-dependency-managers.md +++ b/docs/supported-dependency-managers.md @@ -57,7 +57,8 @@ the following dependencies will be extracted: ### uv -Additionally to PEP 621 dependencies, _deptry_ will +If a `[tool.uv]` section is found under `pyproject.toml`, _deptry_ will assume that the project uses uv, and will, +additionally to PEP 621 dependencies, extract [uv development dependencies](https://docs.astral.sh/uv/concepts/dependencies/#development-dependencies) from `dev-dependencies` entry under `[tool.uv]` section, for instance: @@ -70,6 +71,79 @@ dev-dependencies = [ ] ``` +### Poetry + +Until [version 2.0](https://python-poetry.org/blog/announcing-poetry-2.0.0/), Poetry did not use PEP 621 syntax to +define project dependencies, instead relying on a specific syntax. + +Because Poetry now supports PEP 621, it is now treated as an extension of PEP 621 manager, allowing _deptry_ to retrieve +dependencies defined under `[project.dependencies]` and `[project.optional-dependencies]`, while still allowing +retrieving: + +- regular dependencies from `[tool.poetry.dependencies]` (which is still supported in Poetry 2.0) +- development dependencies from `[tool.poetry.group..dependencies]` and `[tool.poetry.dev-dependencies]` + +#### Regular dependencies + +Which regular dependencies are extracted depend on how you define your dependencies with Poetry, as _deptry_ will +closely match Poetry's behaviour. + +If `[project.dependencies]` is not set, or is empty, regular dependencies will be extracted from +`[tool.poetry.dependencies]`. For instance, in this case: + +```toml title="pyproject.toml" +[project] +name = "foo" + +[tool.poetry.dependencies] +httpx = "0.28.1" +``` + +`httpx` will be extracted as a regular dependency. + +If `[project.dependencies]` contains at least one dependency, then dependencies will **NOT** be extracted from +`[tool.poetry.dependencies]`, as in that case, Poetry will only consider that data in this section enriches dependencies +already defined in `[project.dependencies]` (for instance, to set a specific source), and not defining new dependencies. + +For instance, in this case: + +```toml title="pyproject.toml" +[project] +name = "foo" +dependencies = ["httpx"] + +[tool.poetry.dependencies] +httpx = { git = "https://github.com/encode/httpx", tag = "0.28.1" } +urllib3 = "2.3.0" +``` + +although `[tool.poetry.dependencies]` contain both `httpx` and `urllib3`, only `httpx` will be extracted as a regular +dependency, as `[project.dependencies]` contains at least one dependency, so Poetry itself will not consider `urllib3` +to be a dependency of the project. + +#### Development dependencies + +In Poetry, [development dependencies](https://python-poetry.org/docs/managing-dependencies/#dependency-groups) can be +defined under either (or both): + +- `[tool.poetry.group..dependencies]` sections +- `[tool.poetry.dev-dependencies]` section (which is considered legacy) + +_deptry_ will extract dependencies from all those sections, for instance: + +```toml title="pyproject.toml" +[tool.poetry.dev-dependencies] +mypy = "1.14.1" +ruff = "0.8.6" + +[tool.poetry.group.docs.dependencies] +mkdocs = "1.6.1" + +[tool.poetry.group.test.dependencies] +pytest = "8.3.3" +pytest-cov = "5.0.0" +``` + ### PDM Additionally to PEP 621 dependencies, _deptry_ will @@ -115,43 +189,6 @@ In this example, regular dependencies will be extracted from both `requirements. using [`--pep621-dev-dependency-groups`](usage.md#pep-621-dev-dependency-groups) argument (or its `pep_621_dev_dependency_groups` equivalent in `pyproject.toml`). -## Poetry - -_deptry_ supports -extracting [dependencies defined using Poetry](https://python-poetry.org/docs/pyproject/#dependencies-and-dependency-groups), -and uses the presence of a `[tool.poetry.dependencies]` section in `pyproject.toml` to determine that the project uses -Poetry. - -In a `pyproject.toml` file where Poetry is used, _deptry_ will extract: - -- regular dependencies from entries under `[tool.poetry.dependencies]` section -- development dependencies from entries under each `[tool.poetry.group..dependencies]` section (or the - legacy `[tool.poetry.dev-dependencies]` section) - -For instance, given the following `pyproject.toml` file: - -```toml title="pyproject.toml" -[tool.poetry.dependencies] -python = "^3.10" -orjson = "^3.0.0" -click = { version = "^8.0.0", optional = true } - -[tool.poetry.extras] -cli = ["click"] - -[tool.poetry.group.docs.dependencies] -mkdocs = "1.6.1" - -[tool.poetry.group.test.dependencies] -pytest = "8.3.3" -pytest-cov = "5.0.0" -``` - -the following dependencies will be extracted: - -- regular dependencies: `orjson`, `click` -- development dependencies: `mkdocs`, `pytest`, `pytest-cov` - ## `requirements.txt` (pip, pip-tools) _deptry_ supports extracting [dependencies using