Repository navigation
Conversation
|
Thanks for opening this pull request! This pull request can be checked-out with: git fetch origin pull/3448/head:pr-3448
git checkout pr-3448This pull request can be installed with: pip install git+https://github.com/Pycord-Development/pycord@refs/pull/3448/head |
|
@Paillat-dev I've done 2 files so far and I want your opinion on it. The re-sorting of the keys was done according to the official API docs as that makes stuff faster to find, and when I'm already looking at all types, I figured I might as well do that tedious work too. I also need some info on whether there's any rules on how the classes are split up (see both files I edited) or whether these should be unified into a single object if they are not explicitly separate on the API docs |
There was a problem hiding this comment.
I wanted to look at this but then got caught into other work. However I think there are a couple confusion between all the possible places one of those types can come from and how they can differ (e.g. sending vs receiving vs gateway). Make sure it is clear what is for what use, including whether something is just a base (some bases are private with _ other public).
Maybe including pasting this into some LLM and telling it to compare it with the API and then check if you missed something in your changes/fixes.
| class ApplicationIntegrationTypeConfiguration(TypedDict, total=False): | ||
| oauth2_install_params: AppInstallParams | ||
| class ApplicationIntegrationTypeConfiguration(TypedDict): | ||
| oauth2_install_params: ApplicationInstallParams |
There was a problem hiding this comment.
Docs lists the ouath2_install_params field as optional (and it was that when using total=False).

| target_user: NotRequired[PartialUser] | ||
| target_type: NotRequired[InviteTargetType] | ||
| target_application: NotRequired[PartialAppInfo] | ||
| target_application: NotRequired[PartialApplicationInfo] |
There was a problem hiding this comment.
- https://docs.discord.com/developers/events/gateway-events#invite-create
- https://docs.discord.com/developers/resources/application#application-object
If I get it correctly, the docs state that target_application is not limited to those three fields (see link 2).
| target_type: NotRequired[InviteTargetType] | ||
| target_user: NotRequired[PartialUser] | ||
| target_application: NotRequired[PartialAppInfo] | ||
| target_application: NotRequired[PartialApplicationInfo] |
There was a problem hiding this comment.
Same here. It's clearly not only limited to id, flags and flags_new
| flags: int | ||
| emoji: ActivityEmoji | None | ||
| secrets: ActivitySecrets | ||
| session_id: str | None |
There was a problem hiding this comment.
discord.activity:L590 and discord.activity:L859 still tend to you the session_id, should be dropped.
|
Regarding my comments on class PartialApplicationInfo(TypedDict):
"""Partial application object."""
id: Snowflake
name: NotRequired[str]
icon: NotRequired[str | None]
description: NotRequired[str]
rpc_origins: NotRequired[list[str]]
verify_key: NotRequired[str]
...
class ReadyApplicationInfo(TypedDict):
"""Received from the gateway during the READY event."""
id: Snowflake
flags: int
flags_new: str |
Summary
I've noticed the TypedDicts for the
.typesand.raw_modelsfolders were partly incomplete, partly wrong, and wholly a mess. So before work on correcting typing across the lib can start, this has to be corrected first, as without a correct base of what the API returns, it's all in vain.The main goals are:
total=False(using onlyRequired[...]for required keys) andtotal=True(aka not passing it) and marking non-required keys viaNotRequired[...]. I've opted for the latter approach across the lib, as it's immediately obvious what is and isn't optional, and optional keys should stand out more.Out of scope: Fixing any type errors that result from these changes in any other files, because this is partly the base for all future typing work. These changes should by all means not have any runtime effects, although I will of course do some testing.
Information
examples, ...).
Checklist
type: ignorecomments were used, a comment is also left explaining why.