1010from .markdown import markdown_to_notion , notion_to_markdown
1111from .operations import build_operation
1212from .records import Record
13- from .utils import add_signed_prefix_as_needed , extract_id , remove_signed_prefix_as_needed , slugify
13+ from .utils import (
14+ add_signed_prefix_as_needed ,
15+ extract_id ,
16+ remove_signed_prefix_as_needed ,
17+ slugify ,
18+ )
1419
1520
1621class NotionDate (object ):
@@ -97,8 +102,18 @@ def to_notion(self):
97102
98103
99104class NotionSelect (object ):
100- valid_colors = ["default" , "gray" , "brown" , "orange" , "yellow" ,
101- "green" , "blue" , "purple" , "pink" , "red" ]
105+ valid_colors = [
106+ "default" ,
107+ "gray" ,
108+ "brown" ,
109+ "orange" ,
110+ "yellow" ,
111+ "green" ,
112+ "blue" ,
113+ "purple" ,
114+ "pink" ,
115+ "red" ,
116+ ]
102117 id = None
103118 color = "default"
104119 value = None
@@ -116,11 +131,7 @@ def set_color(self, color):
116131 return color
117132
118133 def to_dict (self ):
119- return {
120- "id" : self .id ,
121- "value" : self .value ,
122- "color" : self .color
123- }
134+ return {"id" : self .id , "value" : self .value , "color" : self .color }
124135
125136
126137class Collection (Record ):
@@ -320,7 +331,9 @@ def _normalize_query_data(data, collection, recursing=False):
320331 if not recursing :
321332 data = deepcopy (data )
322333 if isinstance (data , list ):
323- return [_normalize_query_data (item , collection , recursing = True ) for item in data ]
334+ return [
335+ _normalize_query_data (item , collection , recursing = True ) for item in data
336+ ]
324337 elif isinstance (data , dict ):
325338 # convert slugs to property ids
326339 if "property" in data :
@@ -348,7 +361,9 @@ def __init__(
348361 calendar_by = "" ,
349362 group_by = "" ,
350363 ):
351- assert not (aggregate and aggregations ), "Use only one of `aggregate` or `aggregations` (old vs new format)"
364+ assert not (
365+ aggregate and aggregations
366+ ), "Use only one of `aggregate` or `aggregations` (old vs new format)"
352367 self .collection = collection
353368 self .collection_view = collection_view
354369 self .search = search
@@ -379,7 +394,7 @@ def execute(self):
379394 calendar_by = self .calendar_by ,
380395 group_by = self .group_by ,
381396 ),
382- self
397+ self ,
383398 )
384399
385400
@@ -497,7 +512,9 @@ def _convert_notion_to_python(self, val, prop):
497512 if prop ["type" ] in ["file" ]:
498513 val = (
499514 [
500- add_signed_prefix_as_needed (item [1 ][0 ][1 ], client = self ._client , id = self .id )
515+ add_signed_prefix_as_needed (
516+ item [1 ][0 ][1 ], client = self ._client , id = self .id
517+ )
501518 for item in val
502519 if item [0 ] != ","
503520 ]
@@ -542,7 +559,9 @@ def set_property(self, identifier, val):
542559 if prop ["type" ] in ["select" ] or prop ["type" ] in ["multi_select" ]:
543560 schema_update , prop = self .collection .check_schema_select_options (prop , val )
544561 if schema_update :
545- self .collection .set ("schema.{}.options" .format (prop ["id" ]), prop ["options" ])
562+ self .collection .set (
563+ "schema.{}.options" .format (prop ["id" ]), prop ["options" ]
564+ )
546565
547566 path , val = self ._convert_python_to_notion (val , prop , identifier = identifier )
548567
@@ -686,7 +705,9 @@ def __init__(self, collection, result, query):
686705 self ._client = collection ._client
687706 self ._block_ids = self ._get_block_ids (result )
688707 self .aggregates = result .get ("aggregationResults" , [])
689- self .aggregate_ids = [agg .get ("id" ) for agg in (query .aggregate or query .aggregations )]
708+ self .aggregate_ids = [
709+ agg .get ("id" ) for agg in (query .aggregate or query .aggregations )
710+ ]
690711 self .query = query
691712
692713 def _get_block_ids (self , result ):
0 commit comments