Repository: kedro-org/kedro
File: kedro/io/core.py (Python)

Code before:
        """Checks whether registered dataset exists by calling its `exists()` method."""
        ...

    def release(self, name: str) -> None:
        """Release any cached data associated with a dataset."""
        ...

    def confirm(self, name: str) -> None:
        """Confirm a dataset by its name."""
        ...

    def shallow_copy(self, extra_dataset_patterns: Patterns | None = None) -> _C:
        """Returns a shallow copy of the current object."""
        ...


def _validate_versions(
    datasets: dict[str, AbstractDataset] | None,
    load_versions: dict[str, str],
    save_version: str | None,
) -> tuple[dict[str, str], str | None]:
    """Validates and synchronizes dataset versions for loading and saving.

    Insures consistency of dataset versions across a catalog, particularly
    for versioned datasets. It updates load versions and validates that all
    save versions are consistent.

    Args:
        datasets: A dictionary mapping dataset names to their instances.
            if None, no validation occurs.
        load_versions: A mapping between dataset names and versions
            to load.
        save_version: Version string to be used for ``save`` operations
            by all datasets with enabled versioning.

    Returns:
        Updated ``load_versions`` with load versions specified in the ``datasets``
            and resolved ``save_version``.

    Raises:
        VersionAlreadyExistsError: If a dataset's save version conflicts with
            the catalog's save version.
    """
    if not datasets:
        return load_versions, save_version

    cur_load_versions = load_versions.copy()
    cur_save_version = save_version

    for ds_name, ds in datasets.items():
        # TODO: Move to kedro/io/kedro_data_catalog.py when removing DataCatalog

Review comment (suggestion):
```suggestion
    """Validates and synchronises dataset versions for loading and saving.

    Ensures consistency of dataset versions across a catalog, particularly
    for versioned datasets. It updates load versions and validates that all
    save versions are consistent.
```

Code after:
        """Checks whether registered dataset exists by calling its `exists()` method."""
        ...

    def release(self, name: str) -> None:
        """Release any cached data associated with a dataset."""
        ...

    def confirm(self, name: str) -> None:
        """Confirm a dataset by its name."""
        ...

    def shallow_copy(self, extra_dataset_patterns: Patterns | None = None) -> _C:
        """Returns a shallow copy of the current object."""
        ...


def _validate_versions(
    datasets: dict[str, AbstractDataset] | None,
    load_versions: dict[str, str],
    save_version: str | None,
) -> tuple[dict[str, str], str | None]:
    """Validates and synchronises dataset versions for loading and saving.

    Ensures consistency of dataset versions across a catalog, particularly
    for versioned datasets. It updates load versions and validates that all
    save versions are consistent.

    Args:
        datasets: A dictionary mapping dataset names to their instances.
            if None, no validation occurs.
        load_versions: A mapping between dataset names and versions
            to load.
        save_version: Version string to be used for ``save`` operations
            by all datasets with versioning enabled.

    Returns:
        Updated ``load_versions`` with load versions specified in the ``datasets``
            and resolved ``save_version``.

    Raises:
        VersionAlreadyExistsError: If a dataset's save version conflicts with
            the catalog's save version.
    """
    if not datasets:
        return load_versions, save_version

    cur_load_versions = load_versions.copy()
    cur_save_version = save_version

    for ds_name, ds in datasets.items():
        # TODO: Move to kedro/io/kedro_data_catalog.py when removing DataCatalog