Skip to main content

pyquotes Tests

Single quotes are superior. And if you disagree, there's an option for this as well.

In any case, quotes should be consistent throughout the codebase, and not rely on tools like black that reformat everything. Of course using those tools is perfectly fine if you want this behavior, but sometimes you just want to avoid discussing the quote style during PR reviews).

Usage

$ pyquotes --help
Usage: pyquotes [OPTIONS] FILES...

  A tool that ensures consistent string quotes in your Python code.

  When passing a directory, all *.py files inside will be processed
  recursively.

  If any files needed changes, it exits with a non-zero status code.

Options:
  -V, --version                 Show the version and exit.
  -h, --help                    Show this message and exit.
  -D, --double-quotes           Prefer double quotes.
  -q, --quiet                   Do not output which files have been
                                reformatted.

  -v, --verbose                 Be more verbose and show all files being
                                processed.

  -d, --diff                    Only show diffs without updating files.
  -c, --check-only, --check     Only check files without updating them.
  --exclude PATTERN             Exclude files/directories matching this
                                pattern. Can be used multiple times. Replaces
                                the built-in excludes. Does not apply to
                                explicitly-specified files.

  -X, --extend-exclude PATTERN  Exclude files/directories matching this
                                pattern. Can be used multiple times. Extends
                                the built-in excludes. Does not apply to
                                explicitly-specified files.

Use --diff or --check-only if you want to run this script in CI (usually using flake8-quotes as explained below is the better choice though).

Configuration

exclude, extend-exclude and double-quotes can be configured via the following files (looked up in this order, the first one containing settings is used):

  • .pyquotes.cfg - ConfigParser format, settings or pyquotes section
  • setup.cfg - ConfigParser format, pyquotes or tool:pyquotes section
  • pyproject.toml - TOML format, tool.pyquotes section

Parsing pyproject.toml requires toml to be installed; a warning is emitted if the file exists and no config is found elsewhere and toml is missing.

Note that exclude should not be used in most cases; unless you really need to whitelist something that's excluded by default.

setup.cfg

[pyquotes]
double-quotes = false
extend-exclude =
    htmlcov
    .vscode

The same format can be used in .pyquotes.cfg as well.

pyproject.toml

[tool.pyquotes]
double-quotes = false
extend-exclude = ['htmlcov', '.vscode']

flake8

If you use flake8, you may want to install flake8-quotes to also get warnings if the code currently has incorrect quotes. You can use the following options if you want single quotes:

[flake8]
inline-quotes = single
multiline-quotes = single
docstring-quotes = double
avoid-escape = true

Note that flake8-quotes is completely independent from this tool, so inconsistencies are possible. Please open an issue if you discover any such cases.

Metadata

Release files for pyquotes 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyquotes 1.0.0
File Size Uploaded
pyquotes-1.0.0.tar.gz 10.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyquotes 1.0.0
File Interpreter ABI Platform
pyquotes-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 20.9 kB

Release files / pyquotes-1.0.0.tar.gz

Download URL pyquotes-1.0.0.tar.gz
Size 10.5 kB
Tags Source
SHA-256 checksum
How to use checksums
6bfc04a350b3c2748ea40738ba8a523dc130dcb7102f5b9494c9d890cac70280
BLAKE2b-256 checksum
How to use checksums
668c062510a3bcf5f5e6e982a7503247331b2502981d93741b6a563118a2c8c3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5

Release files / pyquotes-1.0.0-py3-none-any.whl

Download URL pyquotes-1.0.0-py3-none-any.whl
Size 10.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
635e37462fd97eb75cea25366a56b5baaf2596cfb18734916d6f0bd9c76d1b77
BLAKE2b-256 checksum
How to use checksums
4c470ebc11d07a46b6cdf1ccf7cadc739b604df9d1fb565ba9effc7008d70b1c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page