mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-03 03:56:52 +00:00
Merge branch 'bug/318' into 'master'
Further improve our handling of --select and --ignore Closes #318 See merge request !187
This commit is contained in:
commit
fec980a856
4 changed files with 35 additions and 6 deletions
|
|
@ -74,6 +74,10 @@ class StyleGuide(object):
|
|||
reverse=True,
|
||||
))
|
||||
self._ignored = tuple(sorted(options.ignore, reverse=True))
|
||||
self._using_default_ignore = set(self._ignored) == set(defaults.IGNORE)
|
||||
self._using_default_select = (
|
||||
set(self._selected) == set(defaults.SELECT)
|
||||
)
|
||||
self._decision_cache = {}
|
||||
self._parsed_diff = {}
|
||||
|
||||
|
|
@ -135,14 +139,15 @@ class StyleGuide(object):
|
|||
ignore = find_first_match(code, self._ignored)
|
||||
|
||||
if select and ignore:
|
||||
if self._using_default_ignore and not self._using_default_select:
|
||||
return Decision.Selected
|
||||
return find_more_specific(select, ignore)
|
||||
if extra_select and ignore:
|
||||
return find_more_specific(extra_select, ignore)
|
||||
if select or (extra_select and self._selected == defaults.SELECT):
|
||||
if select or (extra_select and self._using_default_select):
|
||||
return Decision.Selected
|
||||
if select is None and extra_select is None and ignore is not None:
|
||||
return Decision.Ignored
|
||||
if self._selected != defaults.SELECT and select is None:
|
||||
if (select is None and
|
||||
(extra_select is None or not self._using_default_ignore)):
|
||||
return Decision.Ignored
|
||||
return Decision.Selected
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue