Skip to content

Request type hints #259

@lucafaggianelli

Description

@lucafaggianelli

Hey thanks for the amazing library!

I'm using notion sdk to create and modify pages and I find hard to write properties in the right format as explained in Notion API docs https://developers.notion.com/reference/page-property-values this is my snippet of code:

await notion.pages.create(
        parent={
            "type": "database_id",
            "database_id": "my_id",
        },
        properties={
            "Name": {
                "id": "title",
                "title": [{"type": "text", "text": {"content": data.name}}],
            },
            "Email": {"email": data.email or None},
            "Phone": {"phone_number": data.phone or None},
            "Years of Experience": {
                "number": data.years_of_experience,
            },
            "City": {
                "rich_text": [{"type": "text", "text": {"content": data.city or None}}],
            },
            "Notes": {
                "rich_text": [
                    {"type": "text", "text": {"content": data.notes or None}}
                ],
            },
        },
    )

It would be nice to have some helpers like EmailValue("luca@example.com") that creates the right dict for you {"email": "luca@example.com"} and eventually when reading a page it would include also "type": "email"

What do you think? Happy to come up with a PR

Luca

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions