@@ -53,16 +53,22 @@ def _to_flag_model(doc: dict) -> Flag:
5353 return Flag (
5454 flagId = UUID (flag_id ) if flag_id else uuid4 (),
5555 userId = UUID (user_id_raw ) if user_id_raw else UUID (int = 0 ),
56- contentType = ContentTypeEnum (content_type ) if content_type else ContentTypeEnum .VIDEO ,
56+ contentType = ContentTypeEnum (content_type )
57+ if content_type
58+ else ContentTypeEnum .VIDEO ,
5759 contentId = UUID (content_id ) if content_id else UUID (int = 0 ),
5860 reasonCode = reason_code or "other" ,
5961 reasonText = reason_text ,
60- createdAt = norm .get ("createdat" ) or norm .get ("review_date" ) or datetime .now (timezone .utc ),
61- updatedAt = norm .get ("updatedat" ) or norm .get ("review_date" ) or datetime .now (timezone .utc ),
62+ createdAt = norm .get ("createdat" )
63+ or norm .get ("review_date" )
64+ or datetime .now (timezone .utc ),
65+ updatedAt = norm .get ("updatedat" )
66+ or norm .get ("review_date" )
67+ or datetime .now (timezone .utc ),
6268 status = FlagStatusEnum (norm .get ("status" , "open" )),
63- moderatorId = UUID (norm ["moderatorid" ]) if norm . get ( "moderatorid" ) else (
64- UUID ( norm [ "reviewer" ]) if norm .get ("reviewer" ) else None
65- ),
69+ moderatorId = UUID (norm ["moderatorid" ])
70+ if norm .get ("moderatorid" )
71+ else ( UUID ( norm [ "reviewer" ]) if norm . get ( "reviewer" ) else None ),
6672 moderatorNotes = norm .get ("moderatornotes" ),
6773 resolvedAt = norm .get ("resolvedat" ) or norm .get ("review_date" ),
6874 )
@@ -142,7 +148,7 @@ async def create_flag(
142148 # Attempt to insert the document. If the **flags** collection has not
143149 # been created yet Astra will return a ``COLLECTION_NOT_EXIST`` error.
144150 # Instead of surfacing a 500 to the caller we create the collection on
145- #-the-fly and retry once. This mirrors the graceful handling already
151+ # -the-fly and retry once. This mirrors the graceful handling already
146152 # implemented in ``list_flags``.
147153 # ------------------------------------------------------------------
148154
@@ -153,7 +159,9 @@ async def create_flag(
153159 # in environments (e.g. CI) that rely on the stub client.
154160 from astrapy .exceptions .data_api_exceptions import DataAPIResponseException # type: ignore
155161
156- if isinstance (exc , DataAPIResponseException ) and "COLLECTION_NOT_EXIST" in str (exc ):
162+ if isinstance (exc , DataAPIResponseException ) and "COLLECTION_NOT_EXIST" in str (
163+ exc
164+ ):
157165 # Lazily create the collection and retry the insert exactly once.
158166 db = await get_astra_db ()
159167
@@ -168,7 +176,9 @@ async def create_flag(
168176
169177 db_table = await get_table (CONTENT_MOD_TABLE_NAME )
170178 await db_table .insert_one (document = doc )
171- elif isinstance (exc , DataAPIResponseException ) and "UNKNOWN_TABLE_COLUMNS" in str (exc ):
179+ elif isinstance (
180+ exc , DataAPIResponseException
181+ ) and "UNKNOWN_TABLE_COLUMNS" in str (exc ):
172182 # Strip any keys not in the table schema and retry once.
173183 allowed_cols = {
174184 "contentid" ,
@@ -346,7 +356,9 @@ async def action_on_flag(
346356 update_payload_model = {
347357 "status" : new_status ,
348358 "moderatorId" : moderator .userId ,
349- "resolvedAt" : now if new_status in {FlagStatusEnum .APPROVED , FlagStatusEnum .REJECTED } else None ,
359+ "resolvedAt" : now
360+ if new_status in {FlagStatusEnum .APPROVED , FlagStatusEnum .REJECTED }
361+ else None ,
350362 "updatedAt" : now ,
351363 "moderatorNotes" : moderator_notes ,
352364 }
0 commit comments