Skip to content

Conversation

@CoderJoshDK
Copy link
Contributor

@CoderJoshDK CoderJoshDK commented Oct 17, 2025

Note

DO NOT REVIEW THIS. This is very much WIP. Will remove this note when ready to be reviewed.

Summary

Add in reportInconsistentOverload and reportInvalidTypeVarUse pyright rules

Closes #1440

Was actually pretty quick to put this together. So it wasn't wasted work, even if you disagree with this PR.

But as stated in the issue; these overloads were not doing anything anyway. The generic should be provided in the class instead of left as an Unknown. And maybe I am misunderstanding the code. If so, please let me know why this change is wrong.

Updated the docs files because nox was complaining about deprecated usage.

These changes should all be a noop.

Checklist

  • If code changes were made, then they have been tested
    • I have updated the documentation to reflect the changes
    • I have formatted the code properly by running uv run nox -s lint
    • I have type-checked the code by running uv run nox -s 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, ...)

@read-the-docs-community
Copy link

read-the-docs-community bot commented Oct 17, 2025

Documentation build overview

📚 disnake | 🛠️ Build #29999995 | 📁 Comparing 7ef8494 against latest (d9b77a7)


🔍 Preview build

Show files changed (48 files in total): 📝 48 modified | ➕ 0 added | ➖ 0 deleted
File Status
index.html 📝 modified
whats_new.html 📝 modified
api/abc.html 📝 modified
api/activities.html 📝 modified
api/app_commands.html 📝 modified
api/app_info.html 📝 modified
api/audit_logs.html 📝 modified
api/automod.html 📝 modified
api/channels.html 📝 modified
api/clients.html 📝 modified
api/components.html 📝 modified
api/emoji.html 📝 modified
api/entitlements.html 📝 modified
api/events.html 📝 modified
api/exceptions.html 📝 modified
api/guild_scheduled_events.html 📝 modified
api/guilds.html 📝 modified
api/integrations.html 📝 modified
api/interactions.html 📝 modified
api/invites.html 📝 modified
api/localization.html 📝 modified
api/members.html 📝 modified
api/messages.html 📝 modified
api/misc.html 📝 modified
api/permissions.html 📝 modified
api/roles.html 📝 modified
api/skus.html 📝 modified
api/soundboard.html 📝 modified
api/stage_instances.html 📝 modified
api/stickers.html 📝 modified
api/subscriptions.html 📝 modified
api/ui.html 📝 modified
api/users.html 📝 modified
api/utilities.html 📝 modified
api/voice.html 📝 modified
api/webhooks.html 📝 modified
api/widgets.html 📝 modified
ext/tasks/index.html 📝 modified
ext/commands/api/app_commands.html 📝 modified
ext/commands/api/bots.html 📝 modified
ext/commands/api/checks.html 📝 modified
ext/commands/api/cogs.html 📝 modified
ext/commands/api/context.html 📝 modified
ext/commands/api/converters.html 📝 modified
ext/commands/api/exceptions.html 📝 modified
ext/commands/api/help_commands.html 📝 modified
ext/commands/api/misc.html 📝 modified
ext/commands/api/prefix_commands.html 📝 modified

id: int = 0,
row: Optional[int] = None,
) -> None: ...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing those should only be done once V_co TypeVar is changed to have a default.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Going to try to convert as many of these as I can to have a default. Moving this to draft for now. Will return to this PR later.

@CoderJoshDK CoderJoshDK marked this pull request as draft October 17, 2025 20:32
@CoderJoshDK CoderJoshDK force-pushed the pyright branch 2 times, most recently from 1360d1e to 526ef70 Compare October 18, 2025 01:45
@shiftinv shiftinv added the t: refactor/typing/lint Refactors, typing changes and/or linting changes label Oct 19, 2025
@CoderJoshDK CoderJoshDK force-pushed the pyright branch 2 times, most recently from 058e876 to 38f2b66 Compare October 19, 2025 20:50
)
else:
P = TypeVar("P")
BotT = TypeVar("BotT", bound="Union[Bot, AutoShardedBot]")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no real need to specify anything but the TypeVar's name in the else branch of TYPE_CHECKING

Suggested change
BotT = TypeVar("BotT", bound="Union[Bot, AutoShardedBot]")
BotT = TypeVar("BotT")

Comment on lines +122 to +123
CogT = TypeVar("CogT", bound="Optional[Cog]")
ContextT = TypeVar("ContextT", bound="Context")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/DisnakeDev/disnake/pull/1441/files#r2443495659

Suggested change
CogT = TypeVar("CogT", bound="Optional[Cog]")
ContextT = TypeVar("ContextT", bound="Context")
CogT = TypeVar("CogT")
ContextT = TypeVar("ContextT")

V_co = TypeVar("V_co", bound="Optional[View]", covariant=True, default=Optional[View])
else:
ParamSpec = TypeVar
V_co = TypeVar("V_co", bound="Optional[View]", covariant=True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/DisnakeDev/disnake/pull/1441/files#r2443495659

Suggested change
V_co = TypeVar("V_co", bound="Optional[View]", covariant=True)
V_co = TypeVar("V_co")

from ..item import ItemCallbackType
from ..view import View

V_co = TypeVar("V_co", bound="Optional[View]", covariant=True, default=Optional[View])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current behavior is to default to None

Suggested change
V_co = TypeVar("V_co", bound="Optional[View]", covariant=True, default=Optional[View])
V_co = TypeVar("V_co", bound="Optional[View]", covariant=True, default=None)

V_co = TypeVar("V_co", bound="Optional[View]", covariant=True)
V_co = TypeVar("V_co", bound="Optional[View]", covariant=True, default=Optional[View])
else:
V_co = TypeVar("V_co", bound="Optional[View]", covariant=True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/DisnakeDev/disnake/pull/1441/files#r2443495659

Suggested change
V_co = TypeVar("V_co", bound="Optional[View]", covariant=True)
V_co = TypeVar("V_co")

from .item import ItemCallbackType
from .view import View

V_co = TypeVar("V_co", bound="Optional[View]", covariant=True, default=Optional[View])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/DisnakeDev/disnake/pull/1441/files#r2443498907

Suggested change
V_co = TypeVar("V_co", bound="Optional[View]", covariant=True, default=Optional[View])
V_co = TypeVar("V_co", bound="Optional[View]", covariant=True, default=None)

V_co = TypeVar("V_co", bound="Optional[View]", covariant=True, default=Optional[View])
else:
ParamSpec = TypeVar
V_co = TypeVar("V_co", bound="Optional[View]", covariant=True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
V_co = TypeVar("V_co", bound="Optional[View]", covariant=True)
V_co = TypeVar("V_co")

from ..types.components import ActionRowChildComponent as ActionRowChildComponentPayload
from .view import View

V_co = TypeVar("V_co", bound="Optional[View]", covariant=True, default=Optional[View])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
V_co = TypeVar("V_co", bound="Optional[View]", covariant=True, default=Optional[View])
V_co = TypeVar("V_co", bound="Optional[View]", covariant=True, default=None)

Comment on lines +45 to +48
I = TypeVar("I", bound="Item[Any]") # noqa: E741
V_co = TypeVar("V_co", bound="Optional[View]", covariant=True)

SelfViewT = TypeVar("SelfViewT", bound="Optional[View]")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
I = TypeVar("I", bound="Item[Any]") # noqa: E741
V_co = TypeVar("V_co", bound="Optional[View]", covariant=True)
SelfViewT = TypeVar("SelfViewT", bound="Optional[View]")
I = TypeVar("I") # noqa: E741
V_co = TypeVar("V_co")
SelfViewT = TypeVar("SelfViewT")

Comment on lines +170 to +173
def __iter__(cls) -> Iterator[EnumMeta]:
return (cls._enum_member_map_[name] for name in cls._enum_member_names_)

def __reversed__(cls) -> Iterator[EnumMetaT]:
def __reversed__(cls) -> Iterator[EnumMeta]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should be EnumMetaT, before you rebased the TypeVar was incorrectly bound to type[EnumMeta]

@CoderJoshDK
Copy link
Contributor Author

@Enegg thank you for taking a look! Yea, I know a lot of things here are shifted around. This PR is not ready to be looked at anymore. Yes, there are a bunch of incorrect things in here. Will get to patching things up as they come up.

To be able to properly resolve some of the type errors, I need to resolve a bunch of Unknown situations too. So it is taking a bit of time and being a bit more complicated. Might need to lump this change in with a bigger Unknwon push. Will report back later.

@CoderJoshDK
Copy link
Contributor Author

Going to wait for #1449 before I work on this more.

Also, after talking with @onerandomusername, I am going to move typing_extensions outside TYPE_CHECKING for TypeVar so we can consume the default in a much simpler way.

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

Labels

skip news t: refactor/typing/lint Refactors, typing changes and/or linting changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enable reportInconsistentOverload

4 participants