Repository navigation
refactor: Make Object generic - #3450
Paillat-dev wants to merge 2 commits into
Conversation
|
Thanks for opening this pull request! This pull request can be checked-out with: git fetch origin pull/3450/head:pr-3450
git checkout pr-3450This pull request can be installed with: pip install git+https://github.com/Pycord-Development/pycord@refs/pull/3450/head |
|
Can you tell why this helps? |
|
It allows us to type later on other methods as requiring (this PR does not modify runtime behavior) |
|
In your example, the type |
|
My example was not an actual implementation proposal, just a showcase of how it worked & the method I used for testing on my end. That said, I actually believe that it would be beneficial to implement this more than exclusively where In general (at least from my experience type checking all my python strictly), it is common to add verbosity if it means being clearer with what types something actually represents. And this would not impact "standard" users that pass normal "full" objects from the cache for e.g. (which is the case broadly right now, as it is the only supported system [the example method above, @vmphase maybe you have a better idea on how to do this ? |
Summary
Preparation work to allow more places to accept
Objectwithout destroying typing enforcement.example:
It allows us to type later on other methods as requiring
Something | Object[Something]and force users to explicitly pass an object likeObject(my_id, type=SomethingCompatible)whereSomethignCompatibleis compatible withSomething. Before,Object.typewas only used for runtime checks but was not checked at type checking time.(this PR does not modify runtime behavior)
Information
examples, ...).
Checklist
type: ignorecomments were used, a comment is also left explaining why.