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

Code before:
        which will only return matching keys.
        """
        if regex_search == "":
            self._logger.warning("The empty string will not match any datasets")
            return []

        return self.keys(regex_search)

    def _filter_keys(self, regex_search: str | None) -> List[str]:  # noqa: UP006
        if regex_search is None:
            return list(self._datasets.keys())

        try:
            pattern = re.compile(regex_search, flags=re.IGNORECASE)
        except re.error as exc:
            raise SyntaxError(
                f"Invalid regular expression provided: '{regex_search}'"
            ) from exc
        return [ds_name for ds_name in self._datasets if pattern.search(ds_name)]

    def save(self, name: str, data: Any) -> None:
        # TODO: remove when removing old catalog
        """Save data to a registered dataset."""
        self.save_data(name, data)

    def save_data(self, name: str, data: Any) -> None:
        """Save data to a registered dataset."""
        dataset = self.get_dataset(name)

        self._logger.info(
            "Saving data to %s (%s)...",
            _format_rich(name, "dark_orange") if self._use_rich_markup else name,
            type(dataset).__name__,
            extra={"markup": True},
        )

        dataset.save(data)

    def load(self, name: str, version: str | None = None) -> Any:
        # TODO: remove when removing old catalog
        return self.load_data(name, version)

    def load_data(self, name: str, version: str | None = None) -> Any:
        """Loads a registered dataset."""
        load_version = Version(version, None) if version else None
        dataset = self.get_dataset(name, version=load_version)

        self._logger.info(
            "Loading data from %s (%s)...",
            _format_rich(name, "dark_orange") if self._use_rich_markup else name,
            type(dataset).__name__,

Review comment (suggestion):
I am not sure of what is the rationale of keeping ``load_data`` and ``save_data``, but I see this was decided in a TD. Could ou juste reexplain the expected benefit? (I suspect that we keep ``load_data`` to deal with version ; and we keep ``save_data`` for "symmetry")  

Code after:
        This can be filtered by providing an optional regular expression
        which will only return matching keys.
        """
        if regex_search is None:
            return self.keys()

        if regex_search == "":
            self._logger.warning("The empty string will not match any datasets")
            return []

        if not regex_flags:
            regex_flags = re.IGNORECASE

        try:
            pattern = re.compile(regex_search, flags=regex_flags)
        except re.error as exc:
            raise SyntaxError(
                f"Invalid regular expression provided: '{regex_search}'"
            ) from exc
        return [ds_name for ds_name in self.__iter__() if pattern.search(ds_name)]

    def save(self, name: str, data: Any) -> None:
        # TODO: rename input argument when breaking change: name -> ds_name
        """Save data to a registered dataset.

        Args:
            name: A dataset to be saved to.
            data: A data object to be saved as configured in the registered
                dataset.

        Raises:
            DatasetNotFoundError: When a dataset with the given name
                has not yet been registered.

        Example:
        ::

            >>> import pandas as pd
            >>>
            >>> from kedro_datasets.pandas import CSVDataset
            >>>
            >>> cars = CSVDataset(filepath="cars.csv",
            >>>                   load_args=None,
            >>>                   save_args={"index": False})
            >>> catalog = DataCatalog(datasets={'cars': cars})
            >>>
            >>> df = pd.DataFrame({'col1': [1, 2],
            >>>                    'col2': [4, 5],
            >>>                    'col3': [5, 6]})
            >>> catalog.save("cars", df)
        """