do not use self as parameter for static methods

Metadata

ID: python-best-practices/static-method-no-self

Language: Python

Severity: Error

Category: Best Practices

Description

A static method makes no use of an instance. Therefore, the self argument is not needed nor useful and should not be used.

Non-Compliant Code Examples

class Foo:
  @staticmethod
  def foo(self, bar):  # no need to use the self argument with a @staticmethod
     pass

Compliant Code Examples

class Foo:
  @staticmethod
  def foo(bar):
     pass
https://static.datadoghq.com/static/images/logos/github_avatar.svg https://static.datadoghq.com/static/images/logos/vscode_avatar.svg jetbrains

Seamless integrations. Try Datadog Code Analysis