Skip to content
Permalink
Browse files

Merge pull request #95 from jirikuncar/D290-whitespaces

New D210 check for white spaces.
  • Loading branch information...
Nurdok committed Jan 19, 2015
2 parents 56ebdb3 + dcd60de commit 8307b73cac2abd6923892a56c5bacecdbdc7fd6b
Showing with 36 additions and 2 deletions.
  1. +1 −0 .travis.yml
  2. +2 −0 README.rst
  3. +10 −0 pep257.py
  4. +18 −0 test.py
  5. +5 −2 test_pep257.py
@@ -3,6 +3,7 @@
# Travis to install and run "tox" test runner, which is
# configured in tox.ini file.

sudo: false
language: python
install: pip install tox --use-mirrors
script: tox
@@ -114,6 +114,8 @@ are grouped as follows:
+--------------+--------------------------------------------------------------+
| D209 | Put multi-line docstring closing quotes on separate line. |
+--------------+--------------------------------------------------------------+
| D210 | No whitespaces allowed surrounding docstring text. |
+--------------+--------------------------------------------------------------+
| **Quotes issues** |
+--------------+--------------------------------------------------------------+
| D300 | Use """triple double quotes""". |
@@ -777,6 +777,16 @@ def check_newline_after_last_paragraph(self, definition, docstring):
return Error('D209: Put multi-line docstring closing '
'quotes on separate line')

@check_for(Definition)
def check_surrounding_whitespaces(self, definition, docstring):
"""D210: No whitespaces allowed surrounding docstring text."""
if docstring:
lines = eval(docstring).split('\n')
if lines[0].startswith(' ') or \
len(lines) == 1 and lines[0].endswith(' '):
return Error("D210: No whitespaces allowed surrounding "
"docstring text.")

@check_for(Definition)
def check_triple_double_quotes(self, definition, docstring):
r'''D300: Use """triple double quotes""".
18 test.py
@@ -165,6 +165,24 @@ def asdfljdf24():
Description."""


@expect('D210: No whitespaces allowed surrounding docstring text.')
def endswith():
"""Whitespace at the end. """


@expect('D210: No whitespaces allowed surrounding docstring text.')
def around():
""" Whitespace at everywhere. """


@expect('D210: No whitespaces allowed surrounding docstring text.')
def multiline():
""" Whitespace at the begining.
This is the end.
"""


@expect('D300: Expected """-quotes, got \'\'\'-quotes')
def lsfklkjllkjl():
r'''Summary.'''
@@ -1,5 +1,7 @@
"""Use tox or py.test to run the test-suite."""
# -*- coding: utf-8 -*-

"""Use tox or py.test to run the test-suite."""

from __future__ import with_statement

import os
@@ -76,7 +78,8 @@ def test_ignore_list():
no blank line after one-liner is bad. Also this - \"\"\"
return foo
"""
expected_error_codes = set(('D100', 'D400', 'D401', 'D205', 'D209'))
expected_error_codes = set(('D100', 'D400', 'D401', 'D205', 'D209',
'D210'))
mock_open = mock.mock_open(read_data=function_to_check)
with mock.patch('pep257.open', mock_open, create=True):
errors = tuple(pep257.check(['filepath']))

0 comments on commit 8307b73

Please sign in to comment.
You can’t perform that action at this time.