pythonstatic-analysismutabledefault-arguments

How to get a warning when I use a mutable as a default argument?


I accidentally used a mutable default argument (e.g., a list) without knowing it.

Is there a linter or tool that can spot this and warn me?


Solution

  • flake8-bugbear, Pylint, PyCharm, and Pyright can detect this: