Skip to main content

PyPI version Supported Python versions Tests Coverage

flake8-printf-formatting

flake8 plugin which forbids printf-style string formatting

Installation

pip install flake8-printf-formatting

Codes

Code Description
MOD001 do not use printf-style string formatting

Rationale

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.

Bad

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

Good

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: https://gitlab.com/pycqa/flake8
    rev: 3.7.8
    hooks:
    -   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.

Metadata

Release files for flake8-printf-formatting 1.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for flake8-printf-formatting 1.1.2
File Size Uploaded
flake8-printf-formatting-1.1.2.tar.gz 4.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for flake8-printf-formatting 1.1.2
File Interpreter ABI Platform
flake8_printf_formatting-1.1.2-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 8.1 kB

Release files / flake8-printf-formatting-1.1.2.tar.gz

Download URL flake8-printf-formatting-1.1.2.tar.gz
Size 4.0 kB
Tags Source
SHA-256 checksum
How to use checksums
0f9e1308ac290356e4b271d4f26adfc3f9165680a7b6c221503b0f3e155a2784
BLAKE2b-256 checksum
How to use checksums
67838ce88e9dfb6b3eb100bb7535ebddc09b26a7027251ff0d4d9ea79c55958a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.7

Release files / flake8_printf_formatting-1.1.2-py2.py3-none-any.whl

Download URL flake8_printf_formatting-1.1.2-py2.py3-none-any.whl
Size 4.1 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
d908ffabdf08581043a50572744fd60563d82386630b0335445894120089d2df
BLAKE2b-256 checksum
How to use checksums
e2f2ec11ecb58b368c4ff894286cf09564c34d36bd43df6822ee1c2f8825a2fd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.7

Release history Release notifications | RSS feed

This release

1.1.2 This release

2 release files

1.1.0

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page