def METHOD_NAME(cls, value: Any):
    if isinstance(value, cls):
        return value
    if isinstance(value, str):
        return cls.from_string(value)
    try:
        return cls(value)
    except TypeError:
        type_ = type(value).__name__
        raise TypeError(f"{type_} cannot be converted into Key")