Skip to main content

flake8 plugin which forbids printf-style string formatting

Project description

PyPI version Supported Python versions Tests Coverage


flake8 plugin which forbids printf-style string formatting


pip install flake8-printf-formatting


Code Description
MOD001 do not use printf-style string formatting


The official Python 3 documentation doesn't recommend printf-style string formatting:

The formatting operations described here exhibit a variety of quirks that lead to a number of common errors (such as failing to display tuples and dictionaries correctly). Using the newer formatted string literals, the str.format interface, or template strings may help avoid these errors. Each of these alternatives provides their own trade-offs and benefits of simplicity, flexibility, and/or extensibility.


print("Hello, %s!" % name)


print("Hello, {name}!".format(name=name))

Even better

print(f"Hello, {name}!")

As a pre-commit hook

See pre-commit for instructions

Sample .pre-commit-config.yaml:

-   repo:
    rev: 3.7.8
    -   id: flake8
        additional_dependencies: [flake8-printf-formatting]

Release process

  1. Bump version in setup.cfg.
  2. Add a commit "Release vX.Y.Z".
  3. Make sure checks still pass.
  4. Draft a new release with a tag name "X.Y.Z" and describe changes which involved in the release.
  5. Publish the release.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for flake8-printf-formatting, version 1.1.2
Filename, size File type Python version Upload date Hashes
Filename, size flake8_printf_formatting-1.1.2-py2.py3-none-any.whl (4.1 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size flake8-printf-formatting-1.1.2.tar.gz (4.0 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page