import importlib


def import_class(class_string):
    """Returns class object specified by a string.

    https://stackoverflow.com/questions/452969/does-python-have-an-equivalent-to-java-class-forname # noqa

    Args:
        class_string: The string representing a class.

    Raises:
        ValueError if module part of the class is not specified.
    """
    module_name, _, class_name = class_string.rpartition('.')
    if module_name:
        mod = importlib.import_module(module_name)
        return getattr(mod, class_name)
    else:
        return globals()[class_name]