-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
bugSomething isn't workingSomething isn't workingfixesRelated to suggested fixes for violationsRelated to suggested fixes for violations
Description
Summary
unnecessary-empty-iterable-within-deque-call (RUF037) ignores extra arguments. The fix can change behavior.
Starred iterable argument:
$ cat >ruf037_1.py <<'# EOF'
from collections import deque
print(deque([], *[10]).maxlen)
# EOF
$ python ruf037_1.py
10
$ ruff --isolated check ruf037_1.py --select RUF037 --preview --fix
Found 1 error (1 fixed, 0 remaining).
$ python ruf037_1.py
NoneStarred mapping argument:
$ cat >ruf037_2.py <<'# EOF'
from collections import deque
print(deque([], **{"maxlen": 10}).maxlen)
# EOF
$ python ruf037_2.py
10
$ ruff --isolated check ruf037_2.py --select RUF037 --preview --fix
Found 1 error (1 fixed, 0 remaining).
$ python ruf037_2.py
NoneBogus keyword argument:
$ cat >ruf037_3.py <<'# EOF'
from collections import deque
print(deque([], foo=1).maxlen)
# EOF
$ python ruf037_3.py 2>&1 | tail -n 1
TypeError: 'foo' is an invalid keyword argument for deque()
$ ruff --isolated check ruf037_3.py --select RUF037 --preview --fix
Found 1 error (1 fixed, 0 remaining).
$ python ruf037_3.py
NoneVersion
ruff 0.11.13 (5faf72a 2025-06-05)
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingfixesRelated to suggested fixes for violationsRelated to suggested fixes for violations