False-positive S6542 with override (and overload)

  • What language is this for?

  • Which rule?

  • Why do you believe it’s a false-positive/false-negative?
    Because as a user of mypy/pyright, one does not have a choice other than to use Any

  • SonarLint v4.1.0 in VS Code

  • How can we reproduce the problem? Give us a self-contained snippet of code (formatted text, no screenshots)

pip install PySide6-Essentials==6.6.0

Image we want to override QComboBox.addItem:

from typing import Any, overload, override

from PySide6.QtGui import QIcon, QPixmap
from PySide6.QtWidgets import QComboBox

class Class(QComboBox):
    def addItem(self, icon: QIcon | QPixmap, text: str, userData: Any = ...) -> None:

    def addItem(self, text: str, data: Any = ...) -> None:

    def addItem(self, *args: Any, **kwargs: Any) -> None:
        super().addItem(*args, **kwargs)
        # do something special

This triggers a total of 4 false-positive IMHO.

Hello @bers,

Thank you for the detailed post! I would agree this is an issue when overriding and overloading as the type could be dictated by the superclass.
I have created this ticket to track our progress in fixing this issue!

Thank you again for reporting this!