Type nextcord.Embed method parameters more specifically #1076
Labels
3.0
The issue/PR should go for the 3.0 release
p: low
Priority: low - not important to be worked on
s: awaiting review
Status: the issue or PR is awaiting reviews
t: typing
Type: typing - the types doesn't seem quite right
Summary
The methods for
nextcord.Embed
should have properly typed parameters.What is the feature request for?
The core library
The Problem
Currently, many of the parameters in
nextcord.Embed
methods that are supposed to bestr
are typed withAny
. This is not ideal because static type checkers will allow you to provide any object, whether it's appropriate for the method. It's like that so the parameters can support any object then be stringified later, but it could lead to weird problems if not used correctly.Here's an example of this:
nextcord/nextcord/embeds.py
Line 324 in dcadc7e
The Ideal Solution
nextcord.Embed
methods should be typed more precisely to only allow objects that support conversion tostr
. For example, in our example methodset_footer
, if an object that supports conversion to a string (__str__
) is provided, then the type checker will be happy. Otherwise, it will throw an error.This can be accomplished by typing the parameter with a protocol that lists the supported conversion method. Unfortunately, Python does not have a built-in protocol for conversion to a string because technically every object can be converted to a string. We will have to make our own.
The Current Solution
No response
Additional Context
As discussed on the Discord Server, this issue will be for v3.
The text was updated successfully, but these errors were encountered: