Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/atugushev/flake8-printf-formatting
flake8 plugin that forbids printf-style string formatting
https://github.com/atugushev/flake8-printf-formatting
flake8 flake8-plugin formatting printf qa quality-assurance
Last synced: about 2 months ago
JSON representation
flake8 plugin that forbids printf-style string formatting
- Host: GitHub
- URL: https://github.com/atugushev/flake8-printf-formatting
- Owner: atugushev
- License: mit
- Created: 2019-09-07T17:00:51.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-10-12T05:36:31.000Z (about 3 years ago)
- Last Synced: 2024-10-14T16:40:01.745Z (2 months ago)
- Topics: flake8, flake8-plugin, formatting, printf, qa, quality-assurance
- Language: Python
- Homepage:
- Size: 34.2 KB
- Stars: 11
- Watchers: 2
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-flake8-extensions - flake8-printf-formatting - Report `%`-formatting. (Limitations)
README
[![PyPI version](https://img.shields.io/pypi/v/flake8-printf-formatting.svg)](https://pypi.org/project/flake8-printf-formatting/)
[![Supported Python versions](https://img.shields.io/pypi/pyversions/flake8-printf-formatting.svg)](https://pypi.org/project/flake8-printf-formatting/)
![Tests](https://github.com/atugushev/flake8-printf-formatting/workflows/Tests/badge.svg)
[![Coverage](https://codecov.io/gh/atugushev/flake8-printf-formatting/branch/master/graph/badge.svg)](https://codecov.io/gh/atugushev/flake8-printf-formatting)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](https://docs.python.org/3/library/stdtypes.html#printf-style-string-formatting)
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
```python
print("Hello, %s!" % name)
```### Good
```python
print("Hello, {name}!".format(name=name))
```### Even better
```python
print(f"Hello, {name}!")
```## As a pre-commit hook
See [pre-commit](https://github.com/pre-commit/pre-commit) for instructions
Sample `.pre-commit-config.yaml`:
```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`.
1. Add a commit "Release vX.Y.Z".
1. Make sure checks still pass.
1. [Draft a new release](https://github.com/atugushev/flake8-printf-formatting/releases/new) with a tag name "X.Y.Z" and describe changes which involved in the release.
1. Publish the release.