{"id":1450,"library":"dependency-groups","title":"Dependency Groups (PEP 735 Implementation)","description":"The `dependency-groups` library is an active implementation of PEP 735, a standard defining a mechanism for storing package requirements in `pyproject.toml` files that are not included in built project metadata. This library, currently at version 1.3.1 and maintained by the Python Packaging Authority, enables parsing and resolving these dependency groups, including handling nested group inclusions. It's primarily used for development-time dependencies like testing, linting, or documentation, distinguishing them from runtime or optional user-facing dependencies.","status":"active","version":"1.3.1","language":"en","source_language":"en","source_url":"https://github.com/pypa/dependency-groups","tags":["packaging","dependencies","pyproject.toml","PEP 735","tooling","development-dependencies"],"install":[{"cmd":"pip install dependency-groups","lang":"bash","label":"Core library"},{"cmd":"pip install \"dependency-groups[cli]\"","lang":"bash","label":"With CLI tools (includes tomli for older Pythons)"}],"dependencies":[{"reason":"Required for parsing pyproject.toml. Built-in Python 3.11+, explicit dependency for older Python versions (3.8-3.10) if installing `dependency-groups[cli]`.","package":"tomllib","optional":false}],"imports":[{"note":"A functional interface to resolve a dependency group to a list of strings.","symbol":"resolve","correct":"from dependency_groups import resolve"},{"note":"An object-oriented interface for more advanced resolution and inspection.","symbol":"DependencyGroupResolver","correct":"from dependency_groups import DependencyGroupResolver"}],"quickstart":{"code":"import tomllib\nimport io\nfrom dependency_groups import resolve\n\n# Simulate a pyproject.toml file content\npyproject_content = \"\"\"\n[dependency-groups]\ntest = [\"pytest\", {\"include-group\": \"runtime\"}]\nruntime = [\"flask\"]\nbuild = [\"build\", \"twine\"]\n\"\"\"\n\n# In a real project, you would load from 'pyproject.toml':\n# with open(\"pyproject.toml\", \"rb\") as fp:\n#     pyproject = tomllib.load(fp)\n# groups = pyproject[\"dependency-groups\"]\n\n# For quickstart, load from the string\npyproject = tomllib.load(io.BytesIO(pyproject_content.encode('utf-8')))\ngroups = pyproject[\"dependency-groups\"]\n\n# Resolve the 'test' dependency group\nresolved_test_deps = resolve(groups, \"test\")\nprint(f\"Resolved 'test' group: {resolved_test_deps}\")\n\n# Resolve the 'build' dependency group\nresolved_build_deps = resolve(groups, \"build\")\nprint(f\"Resolved 'build' group: {resolved_build_deps}\")\n","lang":"python","description":"This quickstart demonstrates how to parse `dependency-groups` from a `pyproject.toml` (simulated here as a string) and use the `resolve` function to get a flattened list of requirements for a specific group, including handling nested `include-group` directives."},"warnings":[{"fix":"Consult the documentation of your package manager (e.g., `pip`, `uv`, `poetry`, `pdm`) for their current level of PEP 735 support. Keep tools updated to their latest versions.","message":"PEP 735 (Dependency Groups) is a relatively new standard (accepted October 2024). While `dependency-groups` implements the specification, broader tooling support (e.g., `pip`, `uv`, `poetry`) is still evolving. Ensure your entire toolchain supports dependency groups as expected.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Use distinct names for your dependency groups (in `[dependency-groups]`) and optional dependencies (in `[project.optional-dependencies]`) within your `pyproject.toml`.","message":"Avoid creating dependency group names that match existing `project.optional-dependencies` names. PEP 735 advises against this, and tools may treat such name collisions as errors or lead to confusing behavior due to overlapping install UX.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Carefully structure your `include-group` declarations in `pyproject.toml` to ensure no circular dependencies exist between your groups.","message":"Dependency group includes must not contain cycles (e.g., group A includes B, and B includes A). Tools implementing PEP 735, including `dependency-groups`, are expected to detect and report errors if cycles are found during resolution.","severity":"gotcha","affected_versions":"All versions"},{"fix":"For runtime optional features that users can install, use `project.optional-dependencies`. For core runtime dependencies, use `project.dependencies`.","message":"Dependency groups are explicitly *not* included in the project's metadata when a package is built and distributed (e.g., to PyPI). They are intended for local development workflows and not for end-user installation via standard package managers.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}