Flake8 string literal validation
Project description
flake8-literal
flake8 plugin to validate string literals.
This plugin is used to enforce consistent styling of string literals, it recognizes inline literals, multline literals, and docstrings. You can choose between single or double quotes for each type of string.
If the avoid-escape
feature is on (default),
it will enforce using the opposite quote type when doing so
avoid the use of escaped quotes.
It also recognizes continuation strings and will enforce a consistent quote style for the entire set when possible.
In addition it checks the usage of raw strings, preventing unnecessary use of raw strings, and using raw strings when doing so will avoid an escaped backslash.
More features coming soon.
Installation
Standard python package installation:
pip install flake8-noqa
Options
literal-inline-quotes
: Quote to use for inline string literals, choices: single, double (default: single)
literal-multiline-quotes
: Quote to use for multiline string literals, choices: single, double (default: single)
literal-docstring-quotes
: Quote to use for docstrings, choices: single, double (default: double)
literal-avoid-escape
: Avoid escapes in inline string literals when possible (enabled by default)
literal-no-avoid-escape
: Disable escape avoidance in inline string literals
literal-include-name
: Include plugin name in messages (default setting)
literal-no-include-name
: Remove plugin name from messages
All options may be specified on the command line with a --
prefix,
or can be placed in your flake8 config file.
Error Codes
Code | Message |
---|---|
LIT001 | Use single/double quotes for string |
LIT002 | Use single/double quotes for multiline string |
LIT003 | Use single/double quotes for docstring |
LIT004 | Use triple single/double quotes for docstring |
LIT010 | Use double/single quotes for string to avoid escaped single quote |
LIT011 | Escaped single/double quote is not necessary |
LIT012 | Use double/single quotes for continuation strings to match |
LIT020 | Remove raw prefix when not using escapes |
LIT021 | Use raw prefix to avoid escaped slash |
Examples
x = "value" <-- LIT001
x = 'aren\'t escapes great?' <-- LIT010
x = ('one' <-- LIT012
"o'clock")
x = r'no need to be raw' <-- LIT020
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
File details
Details for the file flake8_literal-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: flake8_literal-1.0.0-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 358126da94e3edbc2f610c7b0cef1734ca64936fb5c334f0d6abc81cd30ed03d |
|
MD5 | 9425aa5455e2b33da128caf5ec756ead |
|
BLAKE2b-256 | c3aceab9f97427fa2890f4ea15f56b3937af8ef61f9d4bf713399277c623edc5 |