skillfed

flake8-literal

Flake8 string literal validation

flake8-literal v1.5.0 308.1K downloads/30d#7,770 on PyPI5
Copyleft license GNU Lesser General Public License v3 AGING released

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-literal

uv

uv add flake8-literal

poetry

poetry add flake8-literal

Installing 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

Environment :: ConsoleFramework :: Flake8Intended Audience :: DevelopersLicense :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)Programming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Topic :: Software Development :: Libraries :: Python ModulesTopic :: Software Development :: Quality Assurance

Tags

flake8 string literal validationenforce quote style consistencypython string lintingdocstring quote enforcementraw string validationflake8 code style plugin
lintingcode-stylestring-validation

More Python Modules packages