Remove enabled extensions from options.select

When taking advantage of the --select flag for off-by-default
extensions, we neglected to take into account the fact that leaving the
extension names in the select list would cause different behaviour in
pep8. This should remedy this.

Related to GitLab bug #67
This commit is contained in:
Ian Cordasco 2015-08-24 22:18:35 -05:00
parent b8457ebb24
commit 5b7dc3927a

View file

@ -168,9 +168,16 @@ class StyleGuide(object):
def _disable_extensions(parser, options):
ignored_extensions = set(getattr(parser, 'ignored_extensions', []))
select = set(options.select)
enabled_extensions = ignored_extensions.intersection(select)
# Remove any of the selected extensions from the extensions ignored by
# default.
ignored_extensions -= set(options.select)
ignored_extensions -= select
for extension in enabled_extensions:
options.select.remove(extension)
# Whatever is left afterwards should be unioned with options.ignore and
# options.ignore should be updated with that.
options.ignore = tuple(ignored_extensions.union(options.ignore))