def use_pyproject_dependencies(
        self, group: str, dev: bool = False
    ) -> tuple[list[str], Callable[[list[str]], None]]:
        """Get the dependencies array and setter in the pyproject.toml
        Return a tuple of two elements, the first is the dependencies array,
        and the second value is a callable to set the dependencies array back.
        """
        from pdm.formats.base import make_array

        def update_dev_dependencies(deps: list[str]) -> None:
            from tomlkit.container import OutOfOrderTableProxy

            dependency_groups: list[str | dict[str, str]] = tomlkit.array().multiline(True)
            dev_dependencies: list[str] = tomlkit.array().multiline(True)
            for dep in deps:
                if isinstance(dep, str) and dep.startswith("-e"):
                    dev_dependencies.append(dep)
                else:
                    dependency_groups.append(dep)
            if dependency_groups:
                self.pyproject.dependency_groups[group] = dependency_groups
            else:
                self.pyproject.dependency_groups.pop(group, None)
            if dev_dependencies:
                settings.setdefault("dev-dependencies", {})[group] = dev_dependencies
            else:
                settings.setdefault("dev-dependencies", {}).pop(group, None)
            if isinstance(self.pyproject._data["tool"], OutOfOrderTableProxy):
                # In case of a separate table, we have to remove and re-add it to make the write correct.
                # This may change the order of tables in the TOML file, but it's the best we can do.
                # see bug pdm-project/pdm#2056 for details
                del self.pyproject._data["tool"]["pdm"]
                self.pyproject._data["tool"]["pdm"] = settings

        metadata, settings = self.pyproject.metadata, self.pyproject.settings
        if group == "default":
            return metadata.get("dependencies", tomlkit.array()), lambda x: metadata.__setitem__("dependencies", x)
        dev_dependencies = deepcopy(self.pyproject._data.get("dependency-groups", {}))
        for dev_group, items in self.pyproject.settings.get("dev-dependencies", {}).items():
            dev_dependencies.setdefault(dev_group, []).extend(items)
        deps_setter = [
            (
                metadata.get("optional-dependencies", {}),
                lambda x: metadata.setdefault("optional-dependencies", {}).__setitem__(group, x)
                if x
                else metadata.setdefault("optional-dependencies", {}).pop(group, None),
            ),
            (dev_dependencies, update_dev_dependencies),
        ]
        normalized_group = normalize_name(group)
        for deps, setter in deps_setter:
            normalized_groups = {normalize_name(g) for g in deps}
            if group in deps:
                return make_array(deps[group], True), setter
            if normalized_group in normalized_groups:
                raise PdmUsageError(f"Group {group} already exists in another non-normalized form")
        # If not found, return an empty list and a setter to add the group
        return tomlkit.array().multiline(True), deps_setter[int(dev)][1]
Get the dependencies array and setter in the pyproject.toml
        Return a tuple of two elements, the first is the dependencies array,
        and the second value is a callable to set the dependencies array back.
        
src/pdm/project/core.py