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

Code before:

    dataset_type = config.pop(TYPE_KEY)
    class_obj = None
    warning = None
    if isinstance(dataset_type, str):
        if len(dataset_type.strip(".")) != len(dataset_type):
            raise DatasetError(
                "'type' class path does not support relative "
                "paths or paths ending with a dot."
            )
        class_paths = (prefix + dataset_type for prefix in _DEFAULT_PACKAGES)

        for class_path in class_paths:
            tmp, warning = _load_obj(
                class_path
            )  # Load dataset class, capture the warning

            if tmp is not None:
                class_obj = tmp
                break

        if class_obj is None:  # If no valid class was found, raise an error
            error_msg = (
                warning
                if warning
                else f"Class '{dataset_type}' not found, is this a typo?"
            )
            hint = (
                "\nHint: If you are trying to use a dataset from `kedro-datasets`, "
                "make sure that the package is installed in your current environment. "
                "You can do so by running `pip install kedro-datasets` or "
                "`pip install kedro-datasets[<dataset-group>]` to install `kedro-datasets` along with "
                "related dependencies for the specific dataset group."
            )
            raise DatasetError(f"{error_msg}{hint}")

    if not class_obj:
        class_obj = dataset_type

    if not issubclass(class_obj, AbstractDataset):
        raise DatasetError(
            f"Dataset type '{class_obj.__module__}.{class_obj.__qualname__}' "
            f"is invalid: all dataset types must extend 'AbstractDataset'."
        )

    if VERSION_KEY in config:
        # remove "version" key so that it's not passed
        # to the "unversioned" dataset constructor
        message = (
            "'%s' attribute removed from dataset configuration since it is a "
            "reserved word and cannot be directly specified"

Review comment (suggestion):
I'm not sure this error will now ever be reached. I played around with it and if I have a class called `MyCSVDataset` but try to import `YourCSVDataset` in the catalog I get:

```
DatasetError: An exception occurred when parsing config for dataset 'companies':
module 'wizard.my_dataset' has no attribute 'YourCSVDataset'
```




Code after:
            )

    class_obj = None
    error_msg = None
    if isinstance(dataset_type, str):
        if len(dataset_type.strip(".")) != len(dataset_type):
            raise DatasetError(
                "'type' class path does not support relative "
                "paths or paths ending with a dot."
            )
        class_paths = (prefix + dataset_type for prefix in _DEFAULT_PACKAGES)

        for class_path in class_paths:
            tmp, error_msg = _load_obj(
                class_path
            )  # Load dataset class, capture the warning

            if tmp is not None:
                class_obj = tmp
                break

        if class_obj is None:  # If no valid class was found, raise an error
            hint = (
                "\nHint: If you are trying to use a dataset from `kedro-datasets`, "
                "make sure that the package is installed in your current environment. "
                "You can do so by running `pip install kedro-datasets` or "
                "`pip install kedro-datasets[<dataset-group>]` to install `kedro-datasets` along with "
                "related dependencies for the specific dataset group."
            )
            default_error_msg = f"Class '{dataset_type}' not found, is this a typo?"
            raise DatasetError(f"{error_msg if error_msg else default_error_msg}{hint}")

    if not class_obj:
        class_obj = dataset_type

    if not issubclass(class_obj, AbstractDataset):
        raise DatasetError(
            f"Dataset type '{class_obj.__module__}.{class_obj.__qualname__}' "
            f"is invalid: all dataset types must extend 'AbstractDataset'."
        )

    if VERSION_KEY in config:
        # remove "version" key so that it's not passed
        # to the "unversioned" dataset constructor
        message = (
            "'%s' attribute removed from dataset configuration since it is a "
            "reserved word and cannot be directly specified"
        )
        logging.getLogger(__name__).warning(message, VERSION_KEY)
        del config[VERSION_KEY]