flake8-literal
Flake8 string literal validation
What it is and what it does
flake8-literal is a flake8 plugin that validates and enforces consistent styling of string literals in Python code. It checks inline strings, multiline strings, and docstrings, allowing you to configure whether each should use single or double quotes. The plugin also validates raw string usage, preventing unnecessary raw prefixes and requiring them when they avoid escaped backslashes—with special handling for regex patterns where raw strings are commonly used.
The plugin integrates directly into flake8's workflow and reports violations using error codes (LIT001–LIT016) that map to specific quote and raw-string issues. It offers fine-grained configuration options to customize quote preferences per string type and control raw string behavior, making it useful for teams that want to enforce a specific string-literal style across their codebase.
Use it for:
- Enforce single quotes for inline strings and double quotes for docstrings across a team's Python codebase.
- Automatically detect and flag unnecessary raw string prefixes in code that doesn't actually contain escaped characters.
- Require raw strings in regex patterns to avoid escaped backslashes, while allowing them in other contexts.
- Catch inconsistent quote usage in continuation strings and suggest fixes to match the first string in the group.
- Prevent escaped quotes where using the opposite quote type would be clearer and more readable.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
A flake8 plugin that enforces consistent styling of string literals, including quote choice, raw string usage, and docstring formatting.
Yes, if you want automated enforcement of string-literal style in flake8. The plugin is low-friction to install and has no known vulnerabilities. However, the 412-day gap since the last release and aging maintenance status suggest limited active development—consider whether the current feature set meets your needs and whether you're comfortable with slower response to issues or feature requests.
Install
flake8-literal on PyPI
pip
pip install flake8-literaluv
uv add flake8-literalpoetry
poetry add flake8-literalInstalling flake8-literal
Before you install
Low install friction with a single runtime dependency on flake8. Maintenance status is aging—last commit was 2025-06-28 and the package has not seen a release in 412 days, though the repository remains active and unarchived.
License in practice
Licensed under GNU Lesser General Public License v3 (copyleft). Users must comply with LGPLv3+ terms; derivative works and modifications require the same license.
Quickstart
pip install flake8-literal
# Add to .flake8 config or command line:
# [flake8]
# literal-inline-quotes = single
# literal-docstring-quotes = double
# Then run flake8 as normal; the plugin checks automatically
Requires Python 3.12 or later; flake8 must be installed and configured in your project.
Verify before relying
- Whether the 412-day gap since last release indicates active maintenance or dormancy despite recent commits.
- Whether the plugin correctly handles all edge cases in re.compile() detection across different import styles.
Package facts
| License | GNU Lesser General Public License v3 (copyleft) |
| Python support | supports the current Python release (>=3.12) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — flake8 |
| Maintenance | aging — 412 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 308,085/month — #7,770 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: flake8_literal-1.5.0-py3-none-any.whl
Keywords: flake8, string, literal
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
flake8-quotesA flake8 plugin that enforces consistent quote…
permissive · top 5,000 on PyPI
pylint-quotesA Pylint plugin that enforces consistent use of…
permissive · top 15,000 on PyPI
flake8-copyrightA flake8 plugin that enforces the presence of…
unclear · top 15,000 on PyPI
flake8-fixmeA flake8 plugin that detects and flags…
permissive · top 15,000 on PyPI
flake8-no-implicit-concatA flake8 plugin that detects and forbids…
permissive · top 15,000 on PyPI
flake8-rst-docstringsA flake8 plugin that validates Python…
permissive · top 15,000 on PyPI
hackingHacking is a set of flake8 plugins that enforce…
permissive · top 15,000 on PyPI
flake8-implicit-str-concatA Flake8 plugin that detects and reports…
permissive · top 15,000 on PyPI
flake8-logging-formatA flake8 extension that enforces logging best…
permissive · top 15,000 on PyPI
flake8-docstringsIntegrates pydocstyle docstring checking into…
permissive · top 5,000 on PyPI