Skip to content

fix: TypedDicts for API objects - #3448

Draft
ToothyDev wants to merge 2 commits into
masterfrom
fix/types-and-api-objects
Draft

ToothyDev wants to merge 2 commits into
masterfrom
fix/types-and-api-objects

Conversation

@ToothyDev

@ToothyDev ToothyDev commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

I've noticed the TypedDicts for the .types and .raw_models folders 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:

  1. Unify python syntax (currently mixed between total=False (using only Required[...] for required keys) and total=True (aka not passing it) and marking non-required keys via NotRequired[...]. 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.
  2. Add missing, correct wrong, and add non-existing keys in existing dicts.
  3. (Optional) Simplify hierarchy and inheritance, as there currently seem to be random splits of big classes into smaller ones with no apparent rules to it

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

  • This PR fixes an issue.
  • This PR adds something new (e.g. new method or parameters).
  • This PR is a breaking change (e.g. methods or parameters removed/renamed).
  • This PR is not a code change (e.g. documentation, README, typehinting,
    examples, ...).

Checklist

  • I have searched the open pull requests for duplicates.
  • If code changes were made then they have been tested.
    • I have updated the documentation to reflect the changes.
  • If type: ignore comments were used, a comment is also left explaining why.
  • I have updated the changelog to include these changes.
  • I have read the Contributing Guidelines.
  • AI Usage has been disclosed. -> None
    • If AI has been used, I understand fully what the code does

@ToothyDev ToothyDev added help wanted Extra attention is needed priority: low Low Priority API reflection Discord API isn't correctly reflected labels Nov 15, 2026
@github-project-automation github-project-automation Bot moved this to Todo in Pycord Nov 15, 2026
@pycord-app

pycord-app Bot commented Nov 15, 2026

Copy link
Copy Markdown

Thanks for opening this pull request!
Please make sure you have read the Contributing Guidelines and Code of Conduct.

This pull request can be checked-out with:

git fetch origin pull/3448/head:pr-3448
git checkout pr-3448

This pull request can be installed with:

pip install git+https://github.com/Pycord-Development/pycord@refs/pull/3448/head

@ToothyDev

Copy link
Copy Markdown
Contributor Author

@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 app info in particular) or whether these should be unified into a single object if they are not explicitly separate on the API docs

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

API reflection Discord API isn't correctly reflected help wanted Extra attention is needed priority: low Low Priority

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

1 participant