Functional Interface

dependency_groups.resolve(dependency_groups: Mapping[str, str | Mapping[str, str]], /, *groups: str) tuple[str, ...][source]

Resolve a dependency group to a tuple of requirements, as strings.

Parameters:
  • dependency_groups – the parsed contents of the [dependency-groups] table from pyproject.toml

  • groups – the name of the group(s) to resolve

Raises:
  • TypeError – if the inputs appear to be the wrong types

  • ValueError – if the data does not appear to be valid dependency group data

  • LookupError – if group name is absent

  • packaging.requirements.InvalidRequirement – if a specifier is not valid

Example usage:

# in pyproject.toml
[dependency-groups]
test = ["pytest", {include-group = "runtime"}]
runtime = ["flask"]
from dependency_groups import resolve
import tomllib

with open("pyproject.toml", "rb") as fp:
    pyproject = tomllib.load(fp)

groups = pyproject["dependency-groups"]

resolve(groups, "test")  # ['pytest', 'flask']