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

Code before:
        # TODO: remove when removing old catalog
        return copy.copy(self._datasets)

    @datasets.setter
    def datasets(self, value: Any) -> None:
        # TODO: remove when removing old catalog
        raise AttributeError(
            "Operation not allowed. Please use KedroDataCatalog.add() instead."
        )

    @property
    def config_resolver(self) -> CatalogConfigResolver:
        return self._config_resolver

    def __repr__(self) -> str:
        return repr(self._datasets)

    def __contains__(self, dataset_name: str) -> bool:
        """Check if an item is in the catalog as a materialised dataset or pattern."""
        return (
            dataset_name in self._datasets
            or self._config_resolver.match_pattern(dataset_name) is not None
        )

    def __eq__(self, other) -> bool:  # type: ignore[no-untyped-def]
        """Compares two catalogs based on materialised datasets' and datasets' patterns."""
        return (self._datasets, self._config_resolver.list_patterns()) == (
            other._datasets,
            other.config_resolver.list_patterns(),
        )

    def keys(self) -> List[str]:  # noqa: UP006
        """List all dataset names registered in the catalog."""
        return list(self.__iter__())

    def values(self) -> List[AbstractDataset]:  # noqa: UP006
        """List all datasets registered in the catalog."""
        return [self._datasets[key] for key in self]

    def items(self) -> List[tuple[str, AbstractDataset]]:  # noqa: UP006
        """List all dataset names and datasets registered in the catalog."""
        return [(key, self._datasets[key]) for key in self]

    def __iter__(self) -> Iterator[str]:
        yield from self._datasets.keys()

    def __getitem__(self, ds_name: str) -> AbstractDataset:
        """Get a dataset by name from an internal collection of datasets.

        If a dataset is not in the collection but matches any pattern
        it is instantiated and added to the collection first, then returned.

Review comment (suggestion):
```suggestion
        """Compares two catalogs based on materialised datasets and datasets patterns."""
```

Code after:
        # TODO: remove when removing old catalog
        return copy.copy(self._datasets)

    @datasets.setter
    def datasets(self, value: Any) -> None:
        # TODO: remove when removing old catalog
        raise AttributeError(
            "Operation not allowed. Please use KedroDataCatalog.add() instead."
        )

    @property
    def config_resolver(self) -> CatalogConfigResolver:
        return self._config_resolver

    def __repr__(self) -> str:
        return repr(self._datasets)

    def __contains__(self, dataset_name: str) -> bool:
        """Check if an item is in the catalog as a materialised dataset or pattern."""
        return (
            dataset_name in self._datasets
            or self._config_resolver.match_pattern(dataset_name) is not None
        )

    def __eq__(self, other) -> bool:  # type: ignore[no-untyped-def]
        """Compares two catalogs based on materialised datasets and datasets patterns."""
        return (self._datasets, self._config_resolver.list_patterns()) == (
            other._datasets,
            other.config_resolver.list_patterns(),
        )

    def keys(self) -> List[str]:  # noqa: UP006
        """List all dataset names registered in the catalog."""
        return list(self.__iter__())

    def values(self) -> List[AbstractDataset]:  # noqa: UP006
        """List all datasets registered in the catalog."""
        return [self._datasets[key] for key in self]

    def items(self) -> List[tuple[str, AbstractDataset]]:  # noqa: UP006
        """List all dataset names and datasets registered in the catalog."""
        return [(key, self._datasets[key]) for key in self]

    def __iter__(self) -> Iterator[str]:
        yield from self._datasets.keys()

    def __getitem__(self, ds_name: str) -> AbstractDataset:
        """Get a dataset by name from an internal collection of datasets.

        If a dataset is not in the collection but matches any pattern
        it is instantiated and added to the collection first, then returned.