Skip to content

Missing action attributes returned as class instance instead of NoneType #60

Description

@nicolossus

If certain attributes are missing from an action's attributes.yaml, the returned type will be a one of expipe's class instances instead of NoneType.

For example, if entities is not specified in attributes.yaml, then

>>> Action.entities
None

but

>>>type(Action.entities)
expipe.core.PropertyList

This prevents comparisons like

if Action.entities is None:
    ...

In the case of missing attributes, I would expect the returned type to be the proper Python NoneType.

Relevant part in the code for the .entities attribute:

expipe/expipe/core.py

Lines 489 to 492 in baa6efd

@property
def entities(self):
return PropertyList(self._backend.attributes, 'entities', dtype=str, unique=True,
data=self._backend.attributes.get('entities'))

Note that self._backend.attributes.get('entities') is the proper NoneType if the attribute is missing, so the logic of the return could utilize this; for example

@property
def entities(self):
    data = self._backend.attributes.get("entities")
    if data is not None:
        return PropertyList(self._backend.attributes, "entities", dtype=str, unique=True, data=data)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions