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.5.tar.gz (4.7 kB view hashes)

Uploaded Source

Built Distribution

pylint_quotes-0.1.5-py2.py3-none-any.whl (7.2 kB view hashes)

Uploaded Python 2 Python 3

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