Enforce stricter slice operations
See original GitHub issueRule request
Thesis
The list has a set of methods that duplicates operations that you can do with +
operator or slices:
# bad
items += [item]
# good
items.append(item)
# bad
items = [item] + items
# good
items.insert(0, item)
# bad
items += other
# good
items.extend(other)
# bad
items = items[::-1]
# good
items.reverse()
# bad
items = sorted(items)
# good
items.sort()
# bad
other = items[:]
# good
other = items.copy()
# bad
items[:] = []
# good
items.clear()
# bad
items = items[:-1]
# good
items.pop()
Reasoning
We have two ways to do something. Let’s prefer a more descriptive way.
This issue contains a lot of related cases. Consider splitting it by smaller ones.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
What is Network Slicing and How Does it Work in 5G?
Network slicing overlays multiple virtual networks on top of a shared network domain, that is, a set of shared network and computing resources....
Read more >Allow optional strict bounds checking for slices #19831 - GitHub
In a more complex application where the slice bounds are calculated to direct operations to specific parts of an array, miscalculating the ...
Read more >Customized Slicing for 6G: Enforcing Artificial Intelligence on ...
To satisfy stringent requirements of diversified services, network slicing is developed, which enables service-oriented resource allocation ...
Read more >Network Slicing - an overview | ScienceDirect Topics
Network slicing enables the definition of multiple virtual networks on a ... Network Slicing (NS) wraps a particular global operating system resource to ......
Read more >5G Slicing: 4 Crucial Principles for Successful Implementation
Operations will be more difficult than creation. More than five domains for network slice management – understanding all five.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Let’s implement several rules that are not bound to types:
items[::-1]
should not be used. Usereversed
or.reverse()
items[:]
should not be used. Use.copy()
items = items[:-1]
should not be used. Useitems.pop()
@orsinium as always - awesome suggestions! Thanks!
Hmmm, that gives me an idea for one more rule. I’ve made #1071. Thank you, @Eric4Jiang!