Skip to content
This repository has been archived by the owner on Dec 13, 2020. It is now read-only.

Commit

Permalink
Fixed compatibility with latest pep257.
Browse files Browse the repository at this point in the history
pep257 significantly changed configuration handling from 0.6.0 to 0.7.0.
Looks like they support multiple config files that apply only to that
directory and its subdirectories. But the change impacting flake8-pep257
was that pep257 no longer exposes 'ignore' config settings.

Instead it reads the 'ignore' value in a private method and then
subtracts it from all valid error codes and exposes that. Flake8 doesn't
behave this way.

This fix implements my own config file reader using a couple of public
APIs, reading only the top-most (current working directory) config file
(same behavior as pep257 0.6.0).

Fixes #4
  • Loading branch information
Robpol86 committed Nov 15, 2015
1 parent bb71f4b commit 56e1864
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
6 changes: 6 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ Changelog

This project adheres to `Semantic Versioning <http://semver.org/>`_.

1.0.4 - 2015-11-14
------------------

Fixed
* pep257 v0.7.0 compatibility.

1.0.3 - 2015-05-31
------------------

Expand Down
18 changes: 13 additions & 5 deletions flake8_pep257.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"""

import codecs
import os

import pep257
import pep8
Expand Down Expand Up @@ -78,11 +79,18 @@ def parse_options(cls, options):
cls.options['ignore'] = options.ignore

# Handle pep257 options.
opt_parser = pep257.get_option_parser()
setattr(opt_parser, '_get_args', lambda *_: list())
native_options = vars(pep257.get_options(['.'], opt_parser))
native_options.pop('match', None)
native_options.pop('match_dir', None)
config = pep257.RawConfigParser()
for file_name in pep257.ConfigurationParser.PROJECT_CONFIG_FILES:
if config.read(os.path.join(os.path.abspath('.'), file_name)):
break
if not config.has_section('pep257'):
return
native_options = dict()
for option in config.options('pep257'):
if option == 'ignore':
native_options['ignore'] = config.get('pep257', option)
if option in ('explain', 'source'):
native_options[option] = config.getboolean('pep257', option)
native_options['show-source'] = native_options.pop('source', None)
if native_options.get('ignore'):
native_options['ignore'] = native_options['ignore'].split(',')
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ def safe_read(path):
],
description='Flake8 plugin for the pep257 Python utility.',
entry_points={'flake8.extension': 'D = flake8_pep257:Main'},
install_requires=['flake8', 'pep257<0.7.0'],
install_requires=['flake8', 'pep257'],
keywords='flake8 pep257 docstrings',
license='MIT',
long_description=safe_read('README.rst'),
name='flake8-pep257',
py_modules=['flake8_pep257'],
url='https://github.com/Robpol86/flake8-pep257',
version='1.0.3',
version='1.0.4',
zip_safe=True,
)

0 comments on commit 56e1864

Please sign in to comment.