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.

Source Distribution

flake8-printf-formatting-1.1.2.tar.gz (4.0 kB view hashes)

Uploaded Source

Built Distribution

flake8_printf_formatting-1.1.2-py2.py3-none-any.whl (4.1 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page