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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 2 Python 3

File details

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

File metadata

File hashes

Hashes for pylint-quotes-0.1.5.tar.gz
Algorithm Hash digest
SHA256 6677fd6dfb6ecd20020a61e852f4fbc907b69a8ecea30daf31117b0766e50117
MD5 1cd3ebbcfc518653c81593d2486da0d0
BLAKE2b-256 7da7b1ddde1d38c1141ab2d7c51d307ef7f81d62b970fc035ea8db74911821c4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pylint_quotes-0.1.5-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 7d9efc65de044b20c6c922ded3f7afde740dc5a9798f45bb21895b2c80aa87b2
MD5 5cc78a567e4c25aa300c4bf933819e8b
BLAKE2b-256 1869f19c51efaf3951fb570a78243b261a7bf178e66468f3692e1cd225fb4cfb

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