Skip to main content

flake8 plugin which forbids printf-style string formatting

Project description

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.

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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 2Python 3

File details

Details for the file flake8-printf-formatting-1.1.2.tar.gz.

File metadata

  • Download URL: flake8-printf-formatting-1.1.2.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for flake8-printf-formatting-1.1.2.tar.gz
Algorithm Hash digest
SHA256 0f9e1308ac290356e4b271d4f26adfc3f9165680a7b6c221503b0f3e155a2784
MD5 a214263ea5a888d87db7a8a9508c4c88
BLAKE2b-256 67838ce88e9dfb6b3eb100bb7535ebddc09b26a7027251ff0d4d9ea79c55958a

See more details on using hashes here.

File details

Details for the file flake8_printf_formatting-1.1.2-py2.py3-none-any.whl.

File metadata

  • Download URL: flake8_printf_formatting-1.1.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 2, Python 3
  • Uploaded using 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

File hashes

Hashes for flake8_printf_formatting-1.1.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 d908ffabdf08581043a50572744fd60563d82386630b0335445894120089d2df
MD5 95edc2f0b6dc30b09976b3c29814d06d
BLAKE2b-256 e2f2ec11ecb58b368c4ff894286cf09564c34d36bd43df6822ee1c2f8825a2fd

See more details on using hashes here.

Supported by

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