simplifiable-if-statement / R1703#
Message emitted:
The if statement can be replaced with %s
Description:
Used when an if statement can be replaced with 'bool(test)'.
Correct code:
FLYING_THINGS = ["bird", "plane", "superman", "this example"]
def is_flying_animal(an_object):
is_flying = isinstance(an_object, Animal) and an_object.name in FLYING_THINGS
return is_flying
Problematic code:
FLYING_THINGS = ["bird", "plane", "superman", "this example"]
def is_flying_animal(an_object):
if isinstance(an_object, Animal) and an_object in FLYING_THINGS: # [simplifiable-if-statement]
is_flying = True
else:
is_flying = False
return is_flying
Created by the refactoring checker.