{"id":4005,"library":"flake8-builtins","title":"flake8-builtins","description":"flake8-builtins is a plugin for the Flake8 code checker that identifies when Python's built-in functions, types, or modules are used as variable names, function parameters, or class attributes, which can lead to unexpected runtime errors. The current version is 3.1.0, actively maintained with releases tied to new Python versions and features.","status":"active","version":"3.1.0","language":"en","source_language":"en","source_url":"https://github.com/gforcada/flake8-builtins","tags":["flake8","linter","code quality","builtins","python","static analysis"],"install":[{"cmd":"pip install flake8-builtins","lang":"bash","label":"Install with pip"}],"dependencies":[{"reason":"This is a plugin for flake8 and requires flake8 to be installed to function.","package":"flake8","optional":false}],"imports":[{"note":"As a flake8 plugin, flake8-builtins is automatically loaded by flake8. Users typically do not need to import any symbols directly from this library in their Python code. The 'BuiltinsChecker' class is an internal implementation detail.","symbol":"BuiltinsChecker","correct":"N/A"}],"quickstart":{"code":"# my_module.py\n\ndef process_data(list, dict_obj):\n    # A002: argument \"list\" is shadowing a python builtin\n    # A002: argument \"dict_obj\" is shadowing a python builtin\n    max = 10  # A001: variable \"max\" is shadowing a python builtin\n    data = list([1, 2, 3])\n    return data\n\ndef my_func():\n    zip = __import__('zipfile') # A004: import statement \"zip\" is shadowing a Python builtin\n\n# To run this, save it as `my_module.py` and execute in your terminal:\n# pip install flake8 flake8-builtins\n# flake8 my_module.py","lang":"python","description":"Install flake8 and flake8-builtins. Then, simply run the `flake8` command against your Python files. The plugin will automatically detect and report issues related to shadowing built-in names. The example above demonstrates various types of shadowing caught by the plugin, including arguments, variables, and imports."},"warnings":[{"fix":"Update any `flake8` configuration (e.g., `.flake8`, `setup.cfg`, `pyproject.toml`) that references `B00X` error codes to use the new `A00X` codes.","message":"Error codes changed from `B00X` to `A00X` in version 1.0 (released 2017-08-19). This was done to avoid clashes with `flake8-bugbear`.","severity":"breaking","affected_versions":">=1.0"},{"fix":"Rename variables, arguments, class attributes, or imported names that shadow Python built-ins. For intentional shadowing, you can use the `--builtins-ignorelist` option or configure `ignore` in your `flake8` settings for specific codes (e.g., `A001`, `A002`).","message":"Shadowing built-in names (e.g., `list`, `dict`, `max`, `id`) can lead to subtle and hard-to-debug `TypeError` exceptions, as the built-in function/type becomes inaccessible. This is the primary problem `flake8-builtins` aims to solve.","severity":"gotcha","affected_versions":"All"},{"fix":"Avoid naming your Python files or modules after standard library modules, or importing symbols that shadow built-in module names. For specific module names you wish to allow, use the `--builtins-allowed-modules` option in your `flake8` configuration.","message":"As of Python 3.10, `flake8-builtins` includes checks (A004, A005) for shadowing built-in module names (e.g., creating a file `logging.py` or `time.py` or importing a symbol as a builtin name).","severity":"gotcha","affected_versions":">=2.2.0a0"},{"fix":"Ensure your project's Python environment meets the minimum requirement (`>=3.10` for version 3.1.0). Upgrade Python if necessary, or pin to an older `flake8-builtins` version compatible with your Python environment if an upgrade is not feasible.","message":"The `requires_python` metadata indicates compatibility with Python versions. Older Python versions (e.g., 3.7 and 3.8) are no longer supported by recent `flake8-builtins` releases.","severity":"gotcha","affected_versions":">=2.2.0a0"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}