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
```
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
Release history Release notifications | RSS feed
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)
Built Distribution
File details
Details for the file pylint-quotes-0.1.5.tar.gz
.
File metadata
- Download URL: pylint-quotes-0.1.5.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6677fd6dfb6ecd20020a61e852f4fbc907b69a8ecea30daf31117b0766e50117 |
|
MD5 | 1cd3ebbcfc518653c81593d2486da0d0 |
|
BLAKE2b-256 | 7da7b1ddde1d38c1141ab2d7c51d307ef7f81d62b970fc035ea8db74911821c4 |
File details
Details for the file pylint_quotes-0.1.5-py2.py3-none-any.whl
.
File metadata
- Download URL: pylint_quotes-0.1.5-py2.py3-none-any.whl
- Upload date:
- Size: 7.2 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7d9efc65de044b20c6c922ded3f7afde740dc5a9798f45bb21895b2c80aa87b2 |
|
MD5 | 5cc78a567e4c25aa300c4bf933819e8b |
|
BLAKE2b-256 | 1869f19c51efaf3951fb570a78243b261a7bf178e66468f3692e1cd225fb4cfb |