# Buggy code
def _create_from_endpoint_config(
    endpoint_config: Optional[EndpointConfig] = None,
) -> "LockStore":
    """Given an endpoint configuration, create a proper `LockStore` object."""

    if (
        endpoint_config is None
        or endpoint_config.type is None
        or endpoint_config.type == "in_memory"
    ):
        # this is the default type if no lock store type is set

        lock_store = InMemoryLockStore()
    elif endpoint_config.type == "redis":
        lock_store = RedisLockStore(host=endpoint_config.url, **endpoint_config.kwargs)
    else:
        lock_store = _load_from_module_string(endpoint_config.type)

    logger.debug(f"Connected to lock store '{lock_store.__class__.__name__}'.")

    return lock_store


# Traceback (AttributeError)
2020-06-16 14:03:23 INFO     root  - Starting Rasa server on http://localhost:5005
2020-06-16 14:03:24.004532: E tensorflow/stream_executor/cuda/cuda_driver.cc:351] failed call to cuInit: UNKNOWN ERROR (303)
Experienced exception while trying to serve
Traceback (most recent call last):
File "/opt/venv/lib/python3.7/site-packages/rasa/core/lock_store.py", line 261, in _load_from_module_string
lock_store_class = common.class_from_module_path(endpoint_config.type)
AttributeError: 'str' object has no attribute 'type'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/venv/lib/python3.7/site-packages/sanic/app.py", line 1167, in run
serve(**server_settings)
File "/opt/venv/lib/python3.7/site-packages/sanic/server.py", line 892, in serve
trigger_events(before_start, loop)
File "/opt/venv/lib/python3.7/site-packages/sanic/server.py", line 668, in trigger_events
loop.run_until_complete(result)
File "uvloop/loop.pyx", line 1456, in uvloop.loop.Loop.run_until_complete
File "/opt/venv/lib/python3.7/site-packages/rasa/core/run.py", line 245, in load_agent_on_start
_lock_store = LockStore.create(endpoints.lock_store)
File "/opt/venv/lib/python3.7/site-packages/rasa/core/lock_store.py", line 38, in create
return _create_from_endpoint_config(obj)
File "/opt/venv/lib/python3.7/site-packages/rasa/core/lock_store.py", line 250, in _create_from_endpoint_config
lock_store = _load_from_module_string(endpoint_config.type)
File "/opt/venv/lib/python3.7/site-packages/rasa/core/lock_store.py", line 265, in _load_from_module_string
f"Could not find a class based on the module path "
AttributeError: 'str' object has no attribute 'type'
Traceback (most recent call last):
File "/opt/venv/lib/python3.7/site-packages/rasa/core/lock_store.py", line 261, in _load_from_module_string
lock_store_class = common.class_from_module_path(endpoint_config.type)
AttributeError: 'str' object has no attribute 'type'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/venv/bin/rasa", line 8, in <module>
sys.exit(main())
File "/opt/venv/lib/python3.7/site-packages/rasa/__main__.py", line 91, in main
cmdline_arguments.func(cmdline_arguments)
File "/opt/venv/lib/python3.7/site-packages/rasa/cli/run.py", line 114, in run
rasa.run(**vars(args))
File "/opt/venv/lib/python3.7/site-packages/rasa/run.py", line 56, in run
**kwargs,
File "/opt/venv/lib/python3.7/site-packages/rasa/core/run.py", line 216, in serve_application
endpoints.lock_store if endpoints else None
File "/opt/venv/lib/python3.7/site-packages/sanic/app.py", line 1167, in run
serve(**server_settings)
File "/opt/venv/lib/python3.7/site-packages/sanic/server.py", line 892, in serve
trigger_events(before_start, loop)
File "/opt/venv/lib/python3.7/site-packages/sanic/server.py", line 668, in trigger_events
loop.run_until_complete(result)
File "uvloop/loop.pyx", line 1456, in uvloop.loop.Loop.run_until_complete
File "/opt/venv/lib/python3.7/site-packages/rasa/core/run.py", line 245, in load_agent_on_start
_lock_store = LockStore.create(endpoints.lock_store)
File "/opt/venv/lib/python3.7/site-packages/rasa/core/lock_store.py", line 38, in create
return _create_from_endpoint_config(obj)
File "/opt/venv/lib/python3.7/site-packages/rasa/core/lock_store.py", line 250, in _create_from_endpoint_config
lock_store = _load_from_module_string(endpoint_config.type)
File "/opt/venv/lib/python3.7/site-packages/rasa/core/lock_store.py", line 265, in _load_from_module_string
f"Could not find a class based on the module path "
AttributeError: 'str' object has no attribute 'type'

# Fixed code
def _create_from_endpoint_config(
    endpoint_config: Optional[EndpointConfig] = None,
) -> "LockStore":
    """Given an endpoint configuration, create a proper `LockStore` object."""

    if (
        endpoint_config is None
        or endpoint_config.type is None
        or endpoint_config.type == "in_memory"
    ):
        # this is the default type if no lock store type is set

        lock_store = InMemoryLockStore()
    elif endpoint_config.type == "redis":
        lock_store = RedisLockStore(host=endpoint_config.url, **endpoint_config.kwargs)
    else:
        lock_store = _load_from_module_string(endpoint_config)

    logger.debug(f"Connected to lock store '{lock_store.__class__.__name__}'.")

    return lock_store