Erroneous Report of "The number and name of arguments passed to a function should match its parameters" in Python 3.9 for instance method called from @classmethod

  • SonarQube Community Edition
  • Version 9.0 (build 45539)
  • The code smell “The number and name of arguments passed to a function should match its parameters” is raised on for a call to an instance method from a class method in Python 3.9. For example, the following code:
class Foo():
   i = 0
   @classmethod
   def bar_class_method(cls):
     >cls.bar_instance_method(cls)
   def bar_instance_method(self):
      print(self.i)

The code above is valid, the indicated call to the instance method from the class method uses the default initialization of instance variables, but SonarQube raises it as a code smell.

hi @dturchiano_veson ,

welcome to our community. Thanks a lot for reporting this false positive.
I created ticket SONARPY-902 to keep track of it.

1 Like