Skip to content

Commit b7cbe79

Browse files
Add a doc example for simplifiable-if-expression
Refs #5953 Closes #5882
1 parent f4c6a25 commit b7cbe79

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FLYING_THINGS = ["bird", "plane", "superman", "this example"]
2+
3+
def is_flying_animal(an_object):
4+
if isinstance(an_object, Animal) and an_object in FLYING_THINGS: # [simplifiable-if-expression]
5+
is_flying = True
6+
else:
7+
is_not_flying = True
8+
return is_flying, is_not_flying
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
# This is a placeholder for correct code for this message.
1+
FLYING_THINGS = ["bird", "plane", "superman", "this example"]
2+
3+
def is_flying_animal(an_object):
4+
is_flying = isinstance(an_object, Animal) and an_object.name in FLYING_THINGS
5+
return is_flying, not is_flying
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- `Simplifying an 'if' statement with bool() <https://stackoverflow.com/questions/49546992/>`_

0 commit comments

Comments
 (0)