Skip to content

Do not use mutable data structures for argument defaults #9741

@reinhash

Description

@reinhash

When stepping through the code in filters.py, I stumbled upon two instance where a function uses a dictionary as a default value.
While I think this is currently not a big problem and a low prio issue, any mutation to the variable could lead to undefined behaviour. Ruff has a great document concerning this.

How to reproduce:

uv run ruff check .venv/lib/python3.12/site-packages/rest_framework/* | grep B006

Here the lines where I found the problem:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions