{"id":"863b4fad3d277284","repo":"pypa/pip","slug":"dependency-groups-table-was-malformed-in-path","errorCode":null,"errorMessage":"[dependency-groups] table was malformed in {path}. Cannot resolve '--group' option.","messagePattern":"\\[dependency-groups\\] table was malformed in (.+?)\\. Cannot resolve '--group' option\\.","errorType":"exception","errorClass":"InstallationError","httpStatus":null,"severity":"error","filePath":"src/pip/_internal/req/req_dependency_group.py","lineNumber":55,"sourceCode":"                f\"from '{path}': {'; '.join(messages)}\"\n            ) from eg\n\n\ndef _build_resolvers(paths: Iterable[str]) -> dict[str, Any]:\n    resolvers = {}\n    for path in paths:\n        if path in resolvers:\n            continue\n\n        pyproject = _load_pyproject(path)\n        if \"dependency-groups\" not in pyproject:\n            raise InstallationError(\n                f\"[dependency-groups] table was missing from '{path}'. \"\n                \"Cannot resolve '--group' option.\"\n            )\n        raw_dependency_groups = pyproject[\"dependency-groups\"]\n        if not isinstance(raw_dependency_groups, dict):\n            raise InstallationError(\n                f\"[dependency-groups] table was malformed in {path}. \"\n                \"Cannot resolve '--group' option.\"\n            )\n\n        try:\n            resolvers[path] = DependencyGroupResolver(raw_dependency_groups)\n        except ExceptionGroup as eg:\n            # Handle ExceptionGroup from resolver initialization\n            messages = [str(e) for e in eg.exceptions]\n            raise InstallationError(\n                f\"[dependency-groups] data was invalid in {path}: {'; '.join(messages)}\"\n            ) from eg\n\n    return resolvers\n\n\ndef _load_pyproject(path: str) -> dict[str, Any]:\n    \"\"\"","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/pypa/pip/blob/d7d0d0a39494e28ec1c407bd0680e4a4d1067791/src/pip/_internal/req/req_dependency_group.py#L37-L73","documentation":"Raised by _build_resolvers() when a `[dependency-groups]` entry exists in pyproject.toml but is not a TOML table/dict (req_dependency_group.py:54). PEP 735 requires dependency-groups to be a mapping of group-name -> list-of-requirements; an array, string, or scalar at the top level is structurally invalid.","triggerScenarios":"Writing `dependency-groups = [\"pytest\"]` (a flat array) instead of `dependency-groups = {dev = [...]}`. Or `dependency-groups = \"dev\"`. The isinstance(raw_dependency_groups, dict) check fails.","commonSituations":"Misunderstanding PEP 735's structure and listing requirements directly under the key. Copy-pasting from a non-conforming example. Tooling that emits the wrong shape.","solutions":["Restructure [dependency-groups] as a table whose keys are group names and whose values are arrays of requirement strings.","Reload/validate the TOML after editing.","Re-run `pip install --group <name>`."],"exampleFix":"# before\n[dependency-groups]\ndev = [\"pytest\"]  # actually written as: dependency-groups = [\"pytest\"]\n# after\n[dependency-groups]\ndev = [\"pytest\"]\ntest = [\"pytest\", \"coverage\"]","handlingStrategy":"validation","validationCode":"import tomllib\n\ndef assert_dependency_groups_is_dict(path: str) -> None:\n    with open(path, \"rb\") as f:\n        data = tomllib.load(f)\n    raw = data.get(\"dependency-groups\")\n    if not isinstance(raw, dict):\n        raise TypeError(f\"[dependency-groups] in {path} must be a table/dict, got {type(raw).__name__}\")","typeGuard":"import tomllib\n\ndef is_dependency_groups_well_shaped(path: str) -> bool:\n    with open(path, \"rb\") as f:\n        raw = tomllib.load(f).get(\"dependency-groups\")\n    return isinstance(raw, dict)","tryCatchPattern":"null","preventionTips":["Author [dependency-groups] as a table: each key is a group name, each value an array of strings.","Lint pyproject.toml with validate-pyproject or a TOML schema checker.","Avoid flattening requirements directly under the dependency-groups key."],"tags":["dependency-groups","pep735","toml","validation"],"analyzedSha":"d7d0d0a39494e28ec1c407bd0680e4a4d1067791","analyzedAt":"2026-08-04T20:55:04.259Z","schemaVersion":2}