--- id: flake8-mutable version: "1.2.0" license: MIT license_treatment: permissive maintenance: active --- # flake8-mutable — mutable defaults flake8 extension License: permissive · Maintenance: active · Downloads: 166.2K/mo ## 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 above — 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 pip install flake8-mutable uv add flake8-mutable poetry add flake8-mutable ## Installing 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: unspecified - Install friction: low - Maintenance: active - Downloads: 166.2K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags flake8 mutable defaults, detect mutable arguments, python function default args, flake8 code quality, mutable default checker, linting, code-quality, flake8-plugin [View on SkillFed](https://skillfed.io/packages/flake8-mutable) · [View on PyPI](https://pypi.org/project/flake8-mutable/)