do not use self as parameter for static methods

This page is not yet available in Spanish. We are working on its translation.
If you have any questions or feedback about our current translation project, feel free to reach out to us!

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

PREVIEWING: safchain/fix-custom-agent