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
Today I found the following code: self.frame_buffer = deque([], self.frame_buffer_size)
Which, to my understanding, should be the same as self.frame_buffer = deque(maxlen=self.frame_buffer_size)
(but w/o an extra empty literal, be it a list, tuple, set, etc)
Same with x = deque([])/x = deque(()) --> x = deque()
There may be more collection types for which this idea applies.
I think this could be enforced by a linting rule.
The text was updated successfully, but these errors were encountered:
To sum up what I understand. The rule would test for deque calls where the first argument is an empty list or tuple literal because that's redundant
Exactly. Actually any empty iterable if we really wanna be thorough.
But given there's already rules to cover replacing empty iterable calls by literals: At least any empty literal (deque({}) is probably not common, but imo may as well cover it).
Today I found the following code:
self.frame_buffer = deque([], self.frame_buffer_size)
Which, to my understanding, should be the same as
self.frame_buffer = deque(maxlen=self.frame_buffer_size)
(but w/o an extra empty literal, be it a list, tuple, set, etc)
Same with
x = deque([])
/x = deque(())
-->x = deque()
There may be more collection types for which this idea applies.
I think this could be enforced by a linting rule.
The text was updated successfully, but these errors were encountered: