Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New D210 check for white spaces. #95

Merged
merged 2 commits into from Jan 19, 2015
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Next

New D210 check for surrounding whitespaces.

Signed-off-by: Jiri Kuncar <jiri.kuncar@cern.ch>
Reviewed-by: Amir Rachum <nurdok@gmail.com>
  • Loading branch information...
jirikuncar committed Jan 12, 2015
commit 5e9db040a86c190584744176312480f1facd9d43
@@ -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']))
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.