def _translated_groups(self) -> list[str]:
        """Translate default, dev and groups containing ":all" into a list of groups"""
        locked_groups = self.project.lockfile.groups
        if self.is_unset:
            # Default case, return what is in the lock file
            project_groups = list(self.project.iter_groups())
            if locked_groups:
                return [g for g in locked_groups if g in project_groups]
        default, dev, groups = self.default, self.dev, self.groups
        if dev is None:  # --prod is not set, include dev-dependencies
            dev = True
        project = self.project
        optional_groups = {normalize_name(g) for g in project.pyproject.metadata.get("optional-dependencies", {})}
        dev_groups = set(project.pyproject.dev_dependencies)
        groups_set = {normalize_name(g) if g != ":all" else g for g in groups}
        if groups_set & dev_groups:
            if not dev:
                raise PdmUsageError("--prod is not allowed with dev groups and should be left")
        elif dev:
            groups_set.update(dev_groups)
            if self.exclude_non_existing and locked_groups:
                groups_set.intersection_update(locked_groups)
        if ":all" in groups:
            groups_set.discard(":all")
            groups_set.update(optional_groups)
        if default:
            groups_set.add("default")
        groups_set -= {normalize_name(g) for g in self.excluded_groups}

        invalid_groups = groups_set - {normalize_name(g) for g in project.iter_groups()}
        if invalid_groups:
            project.core.ui.echo(
                f"[d]Ignoring non-existing groups: [success]{', '.join(invalid_groups)}[/]",
                err=True,
            )
            groups_set -= invalid_groups
        # Sorts the result in ascending order instead of in random order
        # to make this function pure
        result = sorted(groups_set, key=lambda x: (x != "default", x))
        return result
Translate default, dev and groups containing ":all" into a list of groups
src/pdm/cli/filters.py