Open
Description
Bug description
Pylint reports false positive with the arguments-differ
rule for abstract overloaded static methods declared in a super class, implemented in overridden overloaded static methods in a subclass. The same warnings are generated even if the overridden methods are not abstract in the super class, or just instance methods instead of static methods.
Simple example:
from abc import ABC, abstractmethod
from typing import Literal, overload
class A(ABC):
@staticmethod
@abstractmethod
@overload
def func(*, b: Literal[True]): ...
@staticmethod
@abstractmethod
@overload
def func(*, b: Literal[False], p: int): ...
@staticmethod
@abstractmethod
@overload
def func(*, s: str): ...
@staticmethod
@abstractmethod
def func(*, b: bool | None = None, p: int | None = None, s: str | None = None):
"""The implementation"""
class B(A):
@staticmethod
@overload
def func(*, b: Literal[True]): ...
@staticmethod
@overload
def func(*, b: Literal[False], p: int): ... # WARNING: Number of parameters was 1 in 'A.func' and is now 2 in overriding 'B.func' method Pylint(W0221:arguments-differ)
@staticmethod
@overload
def func(*, s: str): ... # WARNING: Number of parameters was 1 in 'A.func' and is now 1 in overriding 'B.func' method Pylint (W0221:arguments-differ)
@staticmethod
def func(*, b: bool | None = None, p: int | None = None, s: str | None = None):
print(f"Params are '{b}' and '{p}' and {s}.")
It seems Pylint only takes into account the first declaration of the method in the abstract class, but even like this, it generates irrational messages like the second one in the example above.
There are several other issues about this rule, but I have seen none about this specific case.
Configuration
Default configuration of Pylint VSCode Plugin.
Command used
Pylint VSCode plugin.
Pylint output
See in the comments of the example above.
Expected behavior
No warning should be generated because the code is correct.
Pylint version
VSCode extension: ms-python.pylint 2024.0.0 / Pylint version 3.2.7
Python: 3.13.0
OS / Environment
Win 11 Professional