Skip to content

RUF037 ignores extra arguments #18612

@dscorbett

Description

@dscorbett

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
None

Starred 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
None

Bogus 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
None

Version

ruff 0.11.13 (5faf72a 2025-06-05)

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingfixesRelated to suggested fixes for violations

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions