disnake icon indicating copy to clipboard operation
disnake copied to clipboard

typing: use `typing_extensions.NotRequired` in `TypedDict`s

Open shiftinv opened this issue 3 years ago • 0 comments

Summary

Replaces the unwieldy class _XYZOptional(TypedDict, total=False): ... pattern in disnake.types with typing_extensions.NotRequired (added to stdlib typing in 3.11), and sorts most fields to match the order in the api docs. Also adds/fixes a few fields, with no type-checking impact.

I avoided using typing_extensions.Required even if it may have made sense in a couple places, to avoid confusion and make things easier to read/understand.

This will inevitably result in a bunch of merge conflicts over time, I'll try my best to keep this PR updated.

Checklist

  • [x] If code changes were made, then they have been tested
    • [ ] I have updated the documentation to reflect the changes
    • [x] I have formatted the code properly by running task lint
    • [x] I have type-checked the code by running task pyright
  • [ ] 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, ...)

shiftinv avatar Sep 09 '22 00:09 shiftinv