Skip to content

Commit

Permalink
Add a doc example for simplifiable-if-expression
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre-Sassoulas committed May 11, 2022
1 parent 1c90bde commit 54a732e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
8 changes: 8 additions & 0 deletions doc/data/messages/s/simplifiable-if-expression/bad.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FLYING_THINGS = ["bird", "plane", "superman", "this example"]

def is_flying_animal(an_object):
if isinstance(an_object, Animal) and an_object in FLYING_THINGS:
is_flying = True
else:
is_not_flying = True
return is_flying, is_not_flying
5 changes: 5 additions & 0 deletions doc/data/messages/s/simplifiable-if-expression/good.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
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, not is_flying
1 change: 1 addition & 0 deletions doc/data/messages/s/simplifiable-if-expression/related.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- `Simplifying an 'if' statement with bool() <https://stackoverflow.com/questions/49546992/>`_

0 comments on commit 54a732e

Please sign in to comment.