# Buggy code
def from_configuration_file(
    cls, filepath: str = None, **overrides
) -> "NodeConfiguration":
    """Initialize a NodeConfiguration from a JSON file."""

    from nucypher.config.storages import NodeStorage

    node_storage_subclasses = {
        storage._name: storage for storage in NodeStorage.__subclasses__()
    }

    if filepath is None:
        filepath = cls.DEFAULT_CONFIG_FILE_LOCATION

    # Read from disk
    payload = cls._read_configuration_file(filepath=filepath)

    # Sanity check
    try:
        checksum_address = payload["checksum_public_address"]
    except KeyError:
        raise cls.ConfigurationError(
            f"No checksum address specified in configuration file {filepath}"
        )
    else:
        if not eth_utils.is_checksum_address(checksum_address):
            raise cls.ConfigurationError(
                f"Address: '{checksum_address}', specified in {filepath} is not a valid checksum address."
            )

    # Initialize NodeStorage subclass from file (sub-configuration)
    storage_payload = payload["node_storage"]
    storage_type = storage_payload[NodeStorage._TYPE_LABEL]
    storage_class = node_storage_subclasses[storage_type]
    node_storage = storage_class.from_payload(
        payload=storage_payload,
        federated_only=payload["federated_only"],
        serializer=cls.NODE_SERIALIZER,
        deserializer=cls.NODE_DESERIALIZER,
    )

    # Deserialize domains to UTF-8 bytestrings
    domains = list(domain.encode() for domain in payload["domains"])
    payload.update(dict(node_storage=node_storage, domains=domains))

    # Filter out Nones from overrides to detect, well, overrides
    overrides = {k: v for k, v in overrides.items() if v is not None}

    # Instantiate from merged params
    node_configuration = cls(**{**payload, **overrides})

    return node_configuration


# Traceback (builtins.AttributeError)
2019-04-04T17:31:25-0700 [learning-loop#warn] Unhandled error during node learning: Traceback (most recent call last):
File "/home/kieran/.local/share/virtualenvs/nucypher-9CH2v_st/lib/python3.7/site-packages/twisted/internet/base.py", line 1272, in run
self.mainLoop()
File "/home/kieran/.local/share/virtualenvs/nucypher-9CH2v_st/lib/python3.7/site-packages/twisted/internet/base.py", line 1281, in mainLoop
self.runUntilCurrent()
File "/home/kieran/.local/share/virtualenvs/nucypher-9CH2v_st/lib/python3.7/site-packages/twisted/internet/base.py", line 902, in runUntilCurrent
call.func(*call.args, **call.kw)
File "/home/kieran/.local/share/virtualenvs/nucypher-9CH2v_st/lib/python3.7/site-packages/twisted/internet/task.py", line 239, in __call__
d = defer.maybeDeferred(self.f, *self.a, **self.kw)
--- <exception caught here> ---
File "/home/kieran/.local/share/virtualenvs/nucypher-9CH2v_st/lib/python3.7/site-packages/twisted/internet/defer.py", line 151, in maybeDeferred
result = f(*args, **kw)
File "/home/kieran/Git/nucypher/nucypher/network/nodes.py", line 534, in keep_learning_about_nodes
self.learn_from_teacher_node(eager=False)
File "/home/kieran/Git/nucypher/nucypher/network/nodes.py", line 746, in learn_from_teacher_node
if not self.learning_domains.intersection(node.serving_domains):
builtins.AttributeError: 'list' object has no attribute 'intersection'

# Fixed code
def from_configuration_file(
    cls, filepath: str = None, **overrides
) -> "NodeConfiguration":
    """Initialize a NodeConfiguration from a JSON file."""

    from nucypher.config.storages import NodeStorage

    node_storage_subclasses = {
        storage._name: storage for storage in NodeStorage.__subclasses__()
    }

    if filepath is None:
        filepath = cls.DEFAULT_CONFIG_FILE_LOCATION

    # Read from disk
    payload = cls._read_configuration_file(filepath=filepath)

    # Sanity check
    try:
        checksum_address = payload["checksum_public_address"]
    except KeyError:
        raise cls.ConfigurationError(
            f"No checksum address specified in configuration file {filepath}"
        )
    else:
        if not eth_utils.is_checksum_address(checksum_address):
            raise cls.ConfigurationError(
                f"Address: '{checksum_address}', specified in {filepath} is not a valid checksum address."
            )

    # Initialize NodeStorage subclass from file (sub-configuration)
    storage_payload = payload["node_storage"]
    storage_type = storage_payload[NodeStorage._TYPE_LABEL]
    storage_class = node_storage_subclasses[storage_type]
    node_storage = storage_class.from_payload(
        payload=storage_payload,
        federated_only=payload["federated_only"],
        serializer=cls.NODE_SERIALIZER,
        deserializer=cls.NODE_DESERIALIZER,
    )

    # Deserialize domains to UTF-8 bytestrings
    domains = set(domain.encode() for domain in payload["domains"])
    payload.update(dict(node_storage=node_storage, domains=domains))

    # Filter out Nones from overrides to detect, well, overrides
    overrides = {k: v for k, v in overrides.items() if v is not None}

    # Instantiate from merged params
    node_configuration = cls(**{**payload, **overrides})

    return node_configuration