Uploaded image for project: 'SonarPython'
  1. SonarPython
  2. SONARPY-633

FP on rule S5719 when abc.abstractstaticmethod is used

    Details

    • Type: False-Positive
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.8
    • Fix Version/s: None
    • Component/s: Rules
    • Labels:
      None

      Description

      This is a minor False Positive as it concerns a deprecated API. We should still fix it as it is used by some projects (36K hits on Github for "abstractstaticmethod" at the time this is written).

      RSPEC-5719 should avoid raising an issue on methods decorated with abstractstaticmethod defined in abc. We don't even need to check that the decorator is the one from abc module. The name is so explicit that there is no chance the method is not static.

      from abc import ABC, abstractstaticmethod, abstractmethod, abstractclassmethod, abstractproperty
      
      class MyAbstractClass(ABC):
          @abstractproperty
          def myproperty():  # Noncompliant. "self" parameter is missing.
              pass
      
          @abstractclassmethod
          def myclassmethod():  # Noncompliant. "cls" parameter is missing.
              pass
      
          @abstractmethod
          def mymethod():  # Noncompliant. "self" parameter is missing.
              pass
      
          @abstractstaticmethod
          def mystaticmethod():  # Compliant. False Positive
              pass
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                nicolas.harraudeau Nicolas Harraudeau
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated: