Skip to content

Commit

Permalink
filter.py simplifiable-if-statement
Browse files Browse the repository at this point in the history
Code uses the pattern
if test:
    return True
else:
   return False

Pylint alerts on that and suggest a simplification:
The if statement can be replaced with 'return bool(test)' (simplifiable-if-statement)

Hence I removed the if and instead returned the test directly.

That simplifies the code and makes it easier to understand.
  • Loading branch information
evidencebp committed Oct 14, 2024
1 parent 681466c commit 547cf0c
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@ def _country_filter(src, scope, out):
def filter(entry, item):
matching = entry["country"]

if item == matching or item == matching.lower() or item == matching.upper():
return True

else:
return False
return item == matching or item == matching.lower() or item == matching.upper()

return [entry for entry in src if filter(entry, scope)]

Expand Down

0 comments on commit 547cf0c

Please sign in to comment.