flake8-builtins

3.1.0 · active · verified Sat Apr 11

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.

Warnings

Install

Imports

Quickstart

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

view raw JSON →