shayypy / guilded.py

Asynchronous Guilded API wrapper for Python
https://guildedpy.rtfd.io
Other
133 stars 25 forks source link

Better signatures for methods that accept structured content #34

Closed shayypy closed 2 years ago

shayypy commented 2 years ago

Primer

Currently, most methods fitting this description have a signature like this:

async def method(*content, **kwargs):
    ...

... Which is not great for usability. The optimal signature is seen in methods like Messageable.send and ChatMessage.edit:

async def method(
    *pos_content: Optional[Union[str, Embed, File, Emoji, Member]],
    content: Optional[str] = MISSING,
    file: Optional[File] = MISSING,
    files: Optional[Sequence[File]] = MISSING,
    embed: Optional[Embed] = MISSING,
    embeds: Optional[Sequence[Embed]] = MISSING,
    ...
):
    ...

This provides a better typing experience & allows the user to pass content positionally (better for user accounts) or via a keyword-argument (discord.py-compatible & good for consistency).

To-do