False-positive S6542 with re-exported/imported override

  • What language is this for? Python
  • Which rule? S6542
  • Why do you believe it’s a false-positive/false-negative? Because mypy and pyright pass
  • SonarLint 4.2.2


from typing import override


from typing import Any, overload

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

from my_override import override

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

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

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

Hello, @bers and thank you for reporting this false positive!

Indeed, the rule checks strictly for typing.override and typing.overload and I don’t think there’s a good reason for that. It also somehow fails to resolve the fact that this is just a reexported symbol.

I created the following ticket to fix that.