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