Skip to content

Enable reportInconsistentOverload #1440

@CoderJoshDK

Description

@CoderJoshDK

Summary

The pyright linting of reportInconsistentOverload should be enabled

What is the feature request for?

The core library

The Problem

The static check is currently disabled. To enable it, invalid overloading would need to be removed. I am unsure what it was thought to be doing? Overloading the self shouldn't have any effect? Maybe there is some case I am missing?

So far, all offenders of this rule that I have found, are on overloads that only change the type of self.

The Ideal Solution

diff --git a/disnake/ui/item.py b/disnake/ui/item.py
index f1db88d7..468a6cba 100644
--- a/disnake/ui/item.py
+++ b/disnake/ui/item.py
@@ -162,12 +162,6 @@ class Item(WrappedComponent, Generic[V_co]):
 
     __repr_attributes__: ClassVar[Tuple[str, ...]] = ("row",)
 
-    @overload
-    def __init__(self: Item[None]) -> None: ...
-
-    @overload
-    def __init__(self: Item[V_co]) -> None: ...
-
     def __init__(self) -> None:
         self._view: V_co = None  # type: ignore
         self._row: Optional[int] = None

The Current Solution

No response

Additional Context

It might also require going through each instance of these classes and adding in the specified generic type:

@@ -170,7 +170,7 @@ class View:
             await asyncio.sleep(self.__timeout_expiry - now)
 
     def to_components(self) -> List[ActionRowPayload]:
-        def key(item: Item) -> int:
+        def key(item: Item[View]) -> int:
             return item._rendered_row or 0

This should be done anyway, as to avoid unknown scope. But I don't think this step is needed for the removal. That can be its own thing.

So my question is A) what was the overloads trying to do? And B) am I good to remove them, to enable this static check?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions