Skip to main content

Flake8 lint for quotes.

Project description

Build Status

Major update in 2.0.0

We automatically encourage avoiding escaping quotes as per PEP 8. To disable this, use --no-avoid-escape (can be used in configuration file via avoid-escape).

Deprecation notice in 0.3.0

To anticipate multiline support, we are renaming --quotes to --inline-quotes. Please adjust your configurations appropriately.

Usage

If you are using flake8 it’s as easy as:

pip install flake8-quotes

Now you don’t need to worry about people like @sectioneight constantly complaining that you are using double-quotes and not single-quotes.

Warnings

This package adds flake8 warnings with the prefix Q0. You might want to enable this warning inside your flake8 configuration file. Typically that will be .flake8 inside the root folder of your project.

select = Q0

The current set of warnings is:

Code

Description

Q000

Remove bad quotes

Q001

Remove bad quotes from multiline string

Q002

Remove bad quotes from docstring

Q003

Change outer quotes to avoid escaping inner quotes

Configuration

By default, we expect single quotes (’) and look for unwanted double quotes (“). To expect double quotes (”) and find unwanted single quotes (‘), use the CLI option:

flake8 --inline-quotes '"'
# We also support "double" and "single"
# flake8 --inline-quotes 'double'
#
# We also support configuration for multiline quotes
# flake8 --inline-quotes '"' --multiline-quotes "'"
# We also support "'''"
# flake8 --inline-quotes '"' --multiline-quotes "'''"
#
# We also support docstring quotes similarly
# flake8 --inline-quotes '"' --docstring-quotes "'"
# flake8 --inline-quotes '"' --docstring-quotes "'''"

# We also support disabling escaping quotes
# flake8 --no-avoid-escape

or configuration option in tox.ini/setup.cfg.

[flake8]
inline-quotes = "
# We also support "double" and "single"
# inline-quotes = double
#
# We also support configuration for multiline quotes
# multiline-quotes = '
# We also support "'''"
# multiline-quotes = '''
#
# We also support docstring quotes similarly
# docstring-quotes = '
# docstring-quotes = '''
#
# We also support disabling escaping quotes
# avoid-escape = False

Caveats

We follow the PEP8 conventions to avoid backslashes in the string. So, no matter what configuration you are using (single or double quotes) these are always valid strings

s = 'double "quotes" wrapped in singles are ignored'
s = "single 'quotes' wrapped in doubles are ignored"

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flake8-quotes-3.3.1.tar.gz (13.3 kB view details)

Uploaded Source

File details

Details for the file flake8-quotes-3.3.1.tar.gz.

File metadata

  • Download URL: flake8-quotes-3.3.1.tar.gz
  • Upload date:
  • Size: 13.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/2.7.17

File hashes

Hashes for flake8-quotes-3.3.1.tar.gz
Algorithm Hash digest
SHA256 633adca6fb8a08131536af0d750b44d6985b9aba46f498871e21588c3e6f525a
MD5 a869b032d893d28cf63ad1451f8778ad
BLAKE2b-256 3182f4f52cc489b3f08c5b5ce1f6306f12014ed9825c5089835e44761ff395a6

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page