do not compare to True in a condition

このページは日本語には対応しておりません。随時翻訳に取り組んでいます。
翻訳に関してご質問やご意見ございましたら、お気軽にご連絡ください

Metadata

ID: python-best-practices/no-if-true

Language: Python

Severity: Notice

Category: Code Style

Description

Do not use variable == True, just use variable. Comparing against True makes the code more complicated to read.

Non-Compliant Code Examples

if foo == True:  # just used if foo
  print("bar")

Compliant Code Examples

if foo:
  print("bar")
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