Skip to content

B006 doesn’t detect mutable defaults in tuples, generators, and assignment expressions #20004

@dscorbett

Description

@dscorbett

Summary

mutable-argument-default (B006) doesn’t detect certain guaranteed-mutable expressions which should be simple to support: tuples containing mutable expressions, generator expressions, and assignment expressions containing mutable expressions. Example:

$ cat >b006.py <<'# EOF'
def f(x=([],), y=(y for y in "y"), z=(z := [])):
    pass
# EOF

$ ruff --isolated check b006.py --select B006
All checks passed!

Version

ruff 0.12.9 (ef42246 2025-08-14)

Metadata

Metadata

Assignees

Labels

ruleImplementing or modifying a lint rule

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions