Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zheller/flake8-quotes
Flake8 extension for checking quotes in python
https://github.com/zheller/flake8-quotes
Last synced: 28 days ago
JSON representation
Flake8 extension for checking quotes in python
- Host: GitHub
- URL: https://github.com/zheller/flake8-quotes
- Owner: zheller
- License: mit
- Created: 2014-03-10T00:05:08.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2024-03-23T11:51:57.000Z (9 months ago)
- Last Synced: 2024-10-03T03:50:06.273Z (2 months ago)
- Language: Python
- Homepage:
- Size: 83 KB
- Stars: 176
- Watchers: 5
- Forks: 38
- Open Issues: 9
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
- awesome-flake8-extensions - flake8-quotes - Extension for checking quotes in python. (Clean code)
- best-of-python-dev - GitHub - 16% open · ⏱️ 10.02.2024): (Linters & Style Checkers)
README
Flake8 Extension to lint for quotes.
===========================================.. image:: https://travis-ci.org/zheller/flake8-quotes.svg?branch=master
:target: https://travis-ci.org/zheller/flake8-quotes
:alt: Build StatusMajor 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:
.. code:: shell
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... code:: ini
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:
.. code:: shell
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-escapeor configuration option in `tox.ini`/`setup.cfg`.
.. code:: ini
[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 = FalseCaveats
-------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
.. code:: python
s = 'double "quotes" wrapped in singles are ignored'
s = "single 'quotes' wrapped in doubles are ignored"