You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: rules/S7508/python/rule.adoc
+6-10Lines changed: 6 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
This rule raises an issue when the argument to or the return type from the functions `list()`, `tuple()`, `set()`, `sorted()`, or `reversed()` are unnecessarily casted.
1
+
This rule raises an issue when the functions `list()`, `tuple()`, `set()`, `sorted()`, or `reversed()` are unnecessarily wrapped around each other's return values or used to convert values that don't require conversion.
2
2
3
3
== Why is this an issue?
4
4
@@ -7,9 +7,9 @@ Python's built-in functions for processing iterables such as `list()`, `tuple()`
7
7
8
8
== How to fix it
9
9
10
-
When the outer function is given a collection but could be given an iterable, the unnecessary cast to the collection should be removed. For example, in `sorted(list(iterable))`, the outer `sorted()` function can accept an iterable directly, so the inner `list()` call is redundant and should be removed.
10
+
When the outer function is given a collection but could have been given an iterable, the unnecessary conversion should be removed. For example, in `sorted(list(iterable))`, the outer `sorted()` function can accept an iterable directly, so the inner `list()` call is redundant and should be removed.
11
11
12
-
When the function `sorted()` is casted to `list()`, remove the cast, since `sorted()` already returns a list.
12
+
When the function `sorted()` is wrapped with `list()`, remove this conversion operation, since `sorted()` already returns a list.
13
13
14
14
=== Code examples
15
15
@@ -19,8 +19,6 @@ When the function `sorted()` is casted to `list()`, remove the cast, since `sort
0 commit comments