Flake8 String Format Checker

0.3.0 · maintenance · verified Thu Apr 16

An extension for Flake8 that enforces best practices for `str.format` usage. It identifies various issues such as unindexed parameters, insufficient arguments in format calls, mixed implicit and explicit indexing, and unused arguments. The current version, 0.3.0, was released in February 2020, indicating a maintenance release cadence focusing on stability rather than frequent updates.

Common errors

Warnings

Install

Imports

Quickstart

After installation, `flake8-string-format` automatically integrates with Flake8. Simply run `flake8` on your project. The plugin will report errors using codes like P101 (unindexed parameters), P201 (missing arguments), and P301 (unused arguments). Errors can be ignored using the `--ignore` flag or by configuring your `.flake8` file.

# my_module.py
def example_function():
    message = 'Hello {}'.format('World') # P101: format string does contain unindexed parameters
    data = {'name': 'Alice'}
    greeting = 'Hello {name}'.format(**data)
    # The plugin checks string formatting. To run:
    # flake8 my_module.py
    # To ignore a specific error:
    # flake8 --ignore P101 my_module.py

view raw JSON →