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.
pip install flake8-builtinsVerified import paths — ran on the pinned version, not inferred.
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.
Update any `flake8` configuration (e.g., `.flake8`, `setup.cfg`, `pyproject.toml`) that references `B00X` error codes to use the new `A00X` codes.
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`).
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.
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.