Skip to content

Typing Examples #15

@pedroimpulcetto

Description

@pedroimpulcetto

Proposal

Hey there, do we want to use type hints in rows for types?

Example:

from upstash_qstash import Client
from qstash_tokens import QSTASH_TOKEN
from upstash_qstash.schedules import CreateScheduleRequest

client = Client(QSTASH_TOKEN)
schedules = client.schedules()

params: CreateScheduleRequest = {
            "cron": "* * * * *",
            "destination": "https://py-qstash-testing.requestcatcher.com",
            "body": {"hello": "world"},
            "headers": {
                "content-type": "application/json",  # This is the default, but you can override it
            },
        }
res = schedules.create(params)

So, by doing that params: CreateScheduleRequest we can give a really good experience to the user and he can make sure is passing the right params to the method.
Also, he can have a quick check with the VSCode autocomplete feature.

Screenshot 2024-05-03 at 4 49 20 PM

And see if some key is optional or required as well.

Screenshot 2024-05-03 at 4 53 48 PM


If we want to do it, I can work on that 😄

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions