Skip to content

Commit a7e7ca8

Browse files
Added documentation examples for consider-using-any-or-all. (#7152)
Co-authored-by: Pierre Sassoulas <[email protected]>
1 parent 254b260 commit a7e7ca8

File tree

4 files changed

+24
-2
lines changed

4 files changed

+24
-2
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
def any_even(items):
2+
"""Return True if the list contains any even numbers"""
3+
for item in items: # [consider-using-any-or-all]
4+
if item % 2 == 0:
5+
return True
6+
return False
7+
8+
9+
def all_even(items):
10+
"""Return True if the list contains all even numbers"""
11+
for item in items: # [consider-using-any-or-all]
12+
if not item % 2 == 0:
13+
return False
14+
return True

doc/data/messages/c/consider-using-any-or-all/details.rst

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,8 @@
1-
# This is a placeholder for correct code for this message.
1+
2+
def any_even(items):
3+
"""Return True if the list contains any even numbers"""
4+
return any(item % 2 == 0 for item in items)
5+
6+
def all_even(items):
7+
"""Return True if the list contains all even numbers"""
8+
return all(item % 2 == 0 for item in items)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[MAIN]
2+
load-plugins=pylint.extensions.for_any_all

0 commit comments

Comments
 (0)