Registry / testing / flake8-quotes

flake8-quotes

JSON →
library3.4.0pypypi✓ verified 24d ago

flake8-quotes is a Flake8 extension that lints Python code for consistent quote usage. It helps enforce a preferred quote style (single or double) for inline strings, multiline strings, and docstrings, and by default, encourages avoiding escaped quotes as per PEP 8. The current version is 3.4.0, with releases occurring periodically, the latest being in February 2024, indicating active maintenance.

pip install flake8-quotes
INSTALL
IMPORT
SIG · FLAKE8-QUOTES
F
flake8-quotes
testingpythonv3.4.0
Install
2.9s avg
Import
Disk
21MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v3.4.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 20.7MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.9s · import 0.000s · 21MB
21MB installed
● package 21MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

No direct import
This is a flake8 plugin and is not imported directly in Python code.
flake8-quotes integrates with Flake8 automatically upon installation and is configured via Flake8's configuration files (e.g., pyproject.toml, .flake8, setup.cfg).

After installing flake8-quotes, you need to configure Flake8 to enable its checks and specify your preferred quote styles. This is typically done in a `pyproject.toml` file (recommended), `.flake8` file, or `setup.cfg`.

# 1. Create a Python file, e.g., 'bad_quotes.py' # bad_quotes.py message = 'Hello, world!' # Intended to be flagged if double quotes are preferred """This is a docstring.""" # Intended to be flagged if single quotes are preferred # 2. Create a configuration file, e.g., 'pyproject.toml' or '.flake8' # pyproject.toml # [tool.flake8] # inline-quotes = "double" # multiline-quotes = "single" # docstring-quotes = "single" # select = ["E", "F", "W", "Q0"] # avoid-escape = true # This is the default behavior # .flake8 (alternative to pyproject.toml) # [flake8] # inline-quotes = double # multiline-quotes = single # docstring-quotes = single # select = E,F,W,Q0 # avoid-escape = True # 3. Run flake8 from your terminal in the same directory # flake8 bad_quotes.py # Expected output (example, may vary based on exact config and content): # bad_quotes.py:3:11: Q000 Remove bad quotes # bad_quotes.py:5:1: Q002 Remove bad quotes from docstring
flake8 --version
Debug
Known issues
deprecatedThe `--quotes` CLI option and `quotes` configuration setting were renamed to `--inline-quotes` and `inline-quotes` respectively in version 0.3.0.
fix
Update your Flake8 configuration files and CLI commands to use `inline-quotes` instead of `quotes`.
affects: <=0.2.x
breakingIn version 2.0.0, the default behavior changed to automatically encourage avoiding escaping quotes as per PEP 8. This means `avoid-escape` is now `True` by default.
fix
If you relied on the previous behavior where escaping quotes was allowed by default, you must explicitly set `avoid-escape = False` in your configuration or use the `--no-avoid-escape` CLI option.
affects: >=2.0.0
gotchaInstalling flake8-quotes does not automatically enable its checks. You must explicitly include the 'Q0' prefix in your Flake8 `select` configuration.
fix
Add `select = E,F,W,Q0` (or similar, including Q0) to your Flake8 configuration file (e.g., `pyproject.toml`, `.flake8`).
affects: All versions
gotchaWhen configuring flake8-quotes within `pyproject.toml` (especially with tools like `flakeheaven`), string values for options like `inline-quotes` must be explicitly quoted, e.g., `inline-quotes = "double"`.
fix
Ensure that string values for configuration options (e.g., `"single"`, `"double"`) are enclosed in quotes within your `pyproject.toml` under the `[tool.flake8]` section.
affects: All versions when using TOML configs with specific parsers.
Upgrade
Version history
3.4.0latest on PyPI · released Feb 10, 2024
Audit
Dependencies
flake8requiredflake8-quotes is a plugin for the Flake8 linter and requires Flake8 to function.
Agent activity
9 hits · last 30 days
node
8
Resources
flake8-quotes — pip install flake8-quotes · libregistry