Skip to content

Commit 6f1ae7a

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

4 files changed

Lines changed: 14 additions & 2 deletions

File tree

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

doc/data/messages/s/simplifiable-if-expression/details.rst

Lines changed: 0 additions & 1 deletion
This file was deleted.
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)