From 12247890c4cd48f6a6a182162b0da5b673a59c31 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Mon, 3 Jun 2024 16:17:52 +0000 Subject: [PATCH] refactor: replace multiple `==` checks with `in` To check if a variable is equal to one of many values, combine the values into a tuple and check if the variable is contained `in` it instead of checking for equality against each of the values. This is faster, less verbose, and more readable. --- python/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/utils.py b/python/utils.py index af8508ee..4d08046b 100644 --- a/python/utils.py +++ b/python/utils.py @@ -12,7 +12,7 @@ def is_even(x): return x % 2 == 0 def is_prime(x): - if x == 0 or x == 1: + if x in (0, 1): return False for i in range(2, x):