Skip to content

Commit

Permalink
more robust handling of list like objects values
Browse files Browse the repository at this point in the history
  • Loading branch information
lolipopshock committed Feb 22, 2022
1 parent fd11fea commit a6a9506
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/notion_df/values.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
FileObject,
FormulaObject
)
from notion_df.utils import flatten_dict
from notion_df.utils import (
flatten_dict,
is_list_like
)


class BasePropertyValues(BaseModel):
Expand Down Expand Up @@ -106,7 +109,7 @@ def value(self) -> List[str]:

@classmethod
def from_value(cls, values: Union[List[str], str]):
if isinstance(values, list):
if is_list_like(values):
return cls(
multi_select=[SelectOption.from_value(value) for value in values]
)
Expand Down Expand Up @@ -143,7 +146,7 @@ def value(self) -> List[str]:

@classmethod
def from_value(cls, values: Union[List[str], str]):
if isinstance(values, list):
if is_list_like(values):
return cls(relation=[RelationObject.from_value(value) for value in values])
else:
return cls(relation=[RelationObject.from_value(values)])
Expand All @@ -158,7 +161,7 @@ def value(self) -> List[str]:

@classmethod
def from_value(cls, values: Union[List[str], str]):
if isinstance(values, list):
if is_list_like(values):
return cls(people=[UserObject.from_value(value) for value in values])
else:
return cls(people=[UserObject.from_value(values)])
Expand Down

0 comments on commit a6a9506

Please sign in to comment.