Skip to content

Commit

Permalink
fix(handler): set an empty list for aliases with no handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
mostaphaRoudsari committed Mar 20, 2021
1 parent a64d712 commit 0062aae
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
9 changes: 7 additions & 2 deletions pollination_dsl/alias/inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
DAGIntegerInputAlias, DAGNumberInputAlias, DAGBooleanInputAlias, \
DAGJSONObjectInputAlias, DAGArrayInputAlias, DAGFileInputAlias, \
DAGFolderInputAlias, DAGPathInputAlias, DAGLinkedInputAlias
from queenbee.base.basemodel import BaseModel, Field
from queenbee.base.basemodel import BaseModel, Field, validator
from queenbee.io.common import ItemType, IOAliasHandler


Expand Down Expand Up @@ -39,11 +39,16 @@ class _InputAliasBase(BaseModel):
'value can be any strings as long as it has been agreed between client-side '
'developer and author of the recipe.'
)

handler: List[IOAliasHandler] = Field(
...,
None,
description='List of process actions to process the input or output value.'
)

@validator('handler', always=True)
def create_empty_list(cls, v):
return [] if v is None else v

@property
def required(self):
if self.optional:
Expand Down
8 changes: 6 additions & 2 deletions pollination_dsl/alias/outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
DAGFileOutputAlias, DAGPathOutputAlias, DAGJSONObjectOutputAlias,
DAGArrayOutputAlias, DAGLinkedOutputAlias
)
from queenbee.base.basemodel import BaseModel
from queenbee.base.basemodel import BaseModel, validator
from queenbee.io.common import ItemType, IOAliasHandler

from pydantic import Field
Expand Down Expand Up @@ -59,10 +59,14 @@ class _OutputAliasBase(BaseModel):
)

handler: List[IOAliasHandler] = Field(
...,
None,
description='List of process actions to process the input or output value.'
)

@validator('handler', always=True)
def create_empty_list(cls, v):
return [] if v is None else v

@property
def required(self):
if self.optional:
Expand Down

0 comments on commit 0062aae

Please sign in to comment.