Registry / testing / flake8-builtins

flake8-builtins

JSON →
library3.1.0pypypi✓ verified 24d ago

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-builtins
INSTALL
IMPORT
SIG · FLAKE8-BUILTINS
F
flake8-builtins
testingpythonv3.1.0
Install
1.8s avg
Import
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v3.1.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 19.3MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.8s · import 0.000s · 20MB
17MB installed
● package 17MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

BuiltinsChecker
N/A
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.

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.

# my_module.py def process_data(list, dict_obj): # A002: argument "list" is shadowing a python builtin # A002: argument "dict_obj" is shadowing a python builtin max = 10 # A001: variable "max" is shadowing a python builtin data = list([1, 2, 3]) return data def my_func(): zip = __import__('zipfile') # A004: import statement "zip" is shadowing a Python builtin # To run this, save it as `my_module.py` and execute in your terminal: # pip install flake8 flake8-builtins # flake8 my_module.py
flake8 --version
Debug
Known issues
breakingError codes changed from `B00X` to `A00X` in version 1.0 (released 2017-08-19). This was done to avoid clashes with `flake8-bugbear`.
fix
Update any `flake8` configuration (e.g., `.flake8`, `setup.cfg`, `pyproject.toml`) that references `B00X` error codes to use the new `A00X` codes.
affects: >=1.0
gotchaShadowing 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.
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`).
affects: All
gotchaAs 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).
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.
affects: >=2.2.0a0
gotchaThe `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.
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.
affects: >=2.2.0a0
Upgrade
Version history
3.1.0latest on PyPI · released Oct 25, 2025
Audit
Dependencies
flake8requiredThis is a plugin for flake8 and requires flake8 to be installed to function.
Agent activity
6 hits · last 30 days
node
4
Amazon
1
Resources
flake8-builtins — pip install flake8-builtins · libregistry