Skip to content

Commit 4d11dce

Browse files
Add a doc example for simplifiable-if-expression
Refs #5953 Closes #5882
1 parent 89585d4 commit 4d11dce

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
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:
5+
is_flying = True
6+
else:
7+
is_not_flying = True
8+
return is_flying, is_not_flying
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
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)