Skip to main content

Quote consistency checker for Pylint

Project description

# Pylint Quote Checker
A Pylint plugin for checking the consistency of string quotes.

## Example

### before
Below is an example python file that uses inconsistent string quotes.

`example.py`
```python
"""Example python file.
"""


def main(output="default"):
'''Entrypoint to the example script which prints out the
value in the 'output' variable.
'''
print output


if __name__ == "__main__":
main('testing')
```
which would yield
```
No config file found, using default configuration
************* Module example
C: 5, 0: Invalid string quote ", should be ' (invalid-string-quote)
C: 12, 0: Invalid string quote ", should be ' (invalid-string-quote)
C: 6, 0: Invalid docstring quote ''', should be """ (invalid-docstring-quote)

------------------------------------------------------------------
Your code has been rated at 2.50/10 (previous run: 2.50/10, +0.00)
```

### after
Fixing up the example above based on linting recommendations,

`example.py`
```python
"""Example python file.
"""


def main(output='default'):
"""Entrypoint to the example script which prints out the
value in the 'output' variable.
"""
print output


if __name__ == '__main__':
main('testing')
```
which yields
```
No config file found, using default configuration

-------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 2.50/10, +7.50)
```

## Installation

```
pip install pylint-quotes
```

## Usage
To use pylint-quotes, it must loaded in as a plugin when running pylint
```
pylint --load-plugins pylint_quotes <module-or-package>
```

## Checks
pylint-quotes provides a single `StringQuoteChecker` that checks for consistency
between
- single quote string literals
```python
x = 'example'
y = "example"
```
- triple quote strings
```python
""" single line block comments """
'''
multi-line block comments too
'''

x = '''example'''
y = """
example
"""
```
- docstrings (module, class, function)
```python
def x():
'''Example'''
pass

def y():
"""
Multi-line example.
"""
pass
```

## Configuration
The sting quote type can be configured as either 'single' or 'double' in the configuration
file. For example, to check for single quote string literals, double quote triple quoted string,
and double quoted docstrings,
```ini
string-quote=single
triple-quote=double
docstring-quote=double
```

the default configuration is
```ini
string-quote=single
triple-quote=single
docstring-quote=double
```


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

pylint-quotes-0.1.3.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

pylint_quotes-0.1.3-py2.py3-none-any.whl (7.1 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file pylint-quotes-0.1.3.tar.gz.

File metadata

File hashes

Hashes for pylint-quotes-0.1.3.tar.gz
Algorithm Hash digest
SHA256 5fe13f3bcaf4bc7e5b15204de9c7af24da242b9a8288edf3dd611b9b766c86bc
MD5 2351ca090248406e0eeafa75d7a1eb10
BLAKE2b-256 7c887a894a269a58a907fe173282f50d642dcbaa44a0b5d12043f4785347f11b

See more details on using hashes here.

File details

Details for the file pylint_quotes-0.1.3-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for pylint_quotes-0.1.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 1b194e09c16978863afceec4505ad9192340924f3a170659fc5f5f307dbf9711
MD5 1097eeffc8f0a75cc843cc0c97866be7
BLAKE2b-256 a00a372a8219a6a42a9fdba7bdc00aaffb3a9d88d01138022d76c08f6b83764a

See more details on using hashes here.

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