flake8-mutable
mutable defaults flake8 extension
What it is and what it does
flake8-mutable is a linter plugin for flake8 that catches a subtle but common Python gotcha: mutable default arguments. When you define a function with a mutable default like `def func(arg=[])`, that same list object is reused across all calls, so mutations in one call affect subsequent calls. This plugin scans your code and flags these patterns with error codes like M511 for dict defaults.
It integrates directly into flake8's checking pipeline, so once installed, it runs automatically when you invoke flake8 on your codebase. The plugin has no runtime dependencies beyond flake8 itself, making it a lightweight addition to your linting setup. It's designed for developers who want to catch this class of bug early during code review or CI/CD checks.
Use it for:
- Add to your flake8 configuration in CI/CD to catch mutable defaults before code review.
- Use during local development to flag function definitions with mutable defaults as you write.
- Audit an existing codebase for instances of this anti-pattern across many files at once.
- Enforce a team coding standard that prohibits mutable defaults in function signatures.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
A flake8 plugin that detects mutable default arguments in Python function definitions, flagging a common source of unexpected behavior where mutations persist across function calls.
Yes, if you use flake8 and want to catch mutable default arguments automatically. The plugin is lightweight, has no dependencies, and addresses a real Python pitfall. The long gap since the last release (2017) is a minor concern, but the repository remains active and the plugin's scope is narrow enough that it is unlikely to break with new Python versions.
Install
flake8-mutable on PyPI
pip
pip install flake8-mutableuv
uv add flake8-mutablepoetry
poetry add flake8-mutableInstalling flake8-mutable
Before you install
Low friction install with no runtime dependencies. Last release was in 2017 but the repository remains active with a recent commit in 2026, suggesting ongoing maintenance despite infrequent version updates.
License in practice
MIT license is permissive and poses no restrictions on commercial or private use.
Quickstart
pip install flake8-mutable
Then run flake8 on your code:
flake8 your_file.py
flake8 will report violations like:
foo.py:2:14: M511 - mutable default arg of type Dict
Requires flake8 to be installed and available in your environment; the plugin integrates as a flake8 extension.
Verify before relying
- Whether the package actively detects all mutable types (lists, dicts, sets) or if coverage has gaps.
- Current compatibility with recent flake8 versions and Python 3.7+, given the latest release was in 2017.
Package facts
| License | MIT (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 3,399 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 166,166/month — #10,506 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: flake8_mutable-1.2.0-py2-none-any.whl
Keywords: flake8, mutable, arg, kwarg
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
flake8-bugbearA flake8 plugin that detects likely bugs and…
permissive · top 5,000 on PyPI
flake8-loggingA Flake8 plugin that detects and flags common…
permissive · top 15,000 on PyPI
flake8-rst-docstringsA flake8 plugin that validates Python…
permissive · top 15,000 on PyPI
cython-lintA linter for Cython files that checks for…
permissive · top 5,000 on PyPI
flake8-isortIntegrates isort into flake8 linting, reporting…
copyleft · top 5,000 on PyPI
flake8-string-formatA Flake8 plugin that validates string format…
permissive · top 15,000 on PyPI
flake8-pieA flake8 plugin that detects code quality…
permissive · top 15,000 on PyPI
flake8-builtinsA flake8 plugin that detects when Python…
copyleft · top 5,000 on PyPI
flake8-unused-argumentsA flake8 plugin that detects unused function…
permissive · top 15,000 on PyPI
flake8-functionsA flake8 extension that enforces function-level…
permissive · top 15,000 on PyPI