From 3289bd43a53b5677b11bbcfea8e87c7605a031d9 Mon Sep 17 00:00:00 2001 From: ramnes Date: Mon, 25 Dec 2023 23:31:05 +0100 Subject: [PATCH] Only consider arguments when they're handed over The idea is to keep `undefined` values when users don't explicitly set `None`. We still want some hackery to hide `start_cursor=None` from the API thought, because practicality beats purity. :) --- notion_client/helpers.py | 50 ++-------------------------------------- 1 file changed, 2 insertions(+), 48 deletions(-) diff --git a/notion_client/helpers.py b/notion_client/helpers.py index 0953bcb..8aff091 100644 --- a/notion_client/helpers.py +++ b/notion_client/helpers.py @@ -3,59 +3,13 @@ from urllib.parse import urlparse from uuid import UUID -NOT_NULLABLE = ( - "after", - "ai_block", - "archived", - "audio", - "bookmark", - "breadcrumb", - "bulleted_list_item", - "callout", - "code", - "description", - "discussion_id", - "divider", - "embed", - "equation", - "file", - "filter", - "heading_1", - "heading_2", - "heading_3", - "image", - "is_inline", - "link_to_page", - "numbered_list_item", - "page_size", - "pdf", - "properties", - "query", - "quote", - "sort", - "sorts", - "start_cursor", - "synced_block", - "table", - "table_of_contents", - "table_row", - "template", - "title", - "to_do", - "toggle", - "type", - "video", -) - def pick(base: Dict[Any, Any], *keys: str) -> Dict[Any, Any]: """Return a dict composed of key value pairs for keys passed as args.""" result = {} for key in keys: - value = base.get(key) - if value is None and key in NOT_NULLABLE: - continue - result[key] = value + if key in base and key != "start_cursor": + result[key] = base.get(key) return result