Skip to content
Snippets Groups Projects
Commit 6c1cf991 authored by Amir Rachum's avatar Amir Rachum Committed by GitHub
Browse files

Merge pull request #281 from FarmerSez/Feature/support-multi-lined-configs

#250 - Added support for multi-lined config entries
parents 7654dde4 9e89f04d
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -17,6 +17,7 @@ New Features
* Added support for Python 3.6 (#270).
* Specifying an invalid error code prefix (e.g., ``--select=D9``) will print
a warning message to ``stderr`` (#253, #279).
* Configuration files now support multiple-lined entries (#250, #281).
 
Bug Fixes
 
Loading
Loading
snowballstemmer==1.2.1
configparser==3.5.0
from __future__ import with_statement
from setuptools import setup
import sys
 
# Do not update the version manually - it is managed by `bumpversion`.
version = '2.0.1rc'
 
requirements = [
'snowballstemmer',
'six',
]
# Python3 to Python2 backport support.
if sys.version_info[0] == 2:
requirements.append('configparser')
setup(
name='pydocstyle',
version=version,
Loading
Loading
@@ -25,10 +38,7 @@ setup(
packages=('pydocstyle',),
package_dir={'': 'src'},
package_data={'pydocstyle': ['data/*.txt']},
install_requires=[
'snowballstemmer',
'six',
],
install_requires=requirements,
entry_points={
'console_scripts': [
'pydocstyle = pydocstyle.cli:main',
Loading
Loading
Loading
Loading
@@ -7,10 +7,7 @@ from collections import Set, namedtuple
from re import compile as re
 
 
try: # Python 3.x
from ConfigParser import RawConfigParser
except ImportError: # Python 2.x
from configparser import RawConfigParser
from configparser import RawConfigParser
 
 
from .utils import __version__, log
Loading
Loading
@@ -301,7 +298,7 @@ class ConfigurationParser(object):
Returns (options, should_inherit).
 
"""
parser = RawConfigParser()
parser = RawConfigParser(inline_comment_prefixes=('#', ';'))
options = None
should_inherit = True
 
Loading
Loading
@@ -453,6 +450,12 @@ class ConfigurationParser(object):
 
try:
for part in code_parts:
# Dealing with split-lined configurations; The part might begin
# with a whitespace due to the newline character.
part = part.strip()
if not part:
continue
codes_to_add = {code for code in codes
if code.startswith(part)}
if not codes_to_add:
Loading
Loading
Loading
Loading
@@ -277,6 +277,29 @@ def test_sectionless_config_file(env):
assert 'file does not contain a pydocstyle section' not in err
 
 
def test_multiple_lined_config_file(env):
"""Test that .ini files with multi-lined entries are parsed correctly."""
with env.open('example.py', 'wt') as example:
example.write(textwrap.dedent("""\
class Foo(object):
"Doc string"
def foo():
pass
"""))
select_string = ('D100,\n'
' #D103,\n'
' D204, D300 # Just remember - don\'t check D103!')
env.write_config(select=select_string)
out, err, code = env.invoke()
assert code == 1
assert 'D100' in out
assert 'D204' in out
assert 'D300' in out
assert 'D103' not in out
def test_config_path(env):
"""Test that options are correctly loaded from a specific config file.
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment