mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-08 05:54:17 +00:00
Show a nicer message when duplicate entry points are found
This removes the stack trace from the message printed, which is somewhat more friendly, though still treats this misconfiguration as a catastrophic error.
This commit is contained in:
parent
acced5f62a
commit
6167df4992
3 changed files with 20 additions and 5 deletions
|
|
@ -18,7 +18,7 @@ class ExecutionError(Flake8Exception):
|
||||||
"""Exception raised during execution of Flake8."""
|
"""Exception raised during execution of Flake8."""
|
||||||
|
|
||||||
|
|
||||||
class DuplicatePluginEntryPoint(Flake8Exception):
|
class DuplicatePluginEntryPoint(ExecutionError):
|
||||||
"""Exception raised when a plugin entry point is already taken."""
|
"""Exception raised when a plugin entry point is already taken."""
|
||||||
|
|
||||||
FORMAT = (
|
FORMAT = (
|
||||||
|
|
|
||||||
|
|
@ -121,15 +121,18 @@ class Application(object):
|
||||||
This should be the last thing called on the application instance. It
|
This should be the last thing called on the application instance. It
|
||||||
will check certain options and exit appropriately.
|
will check certain options and exit appropriately.
|
||||||
"""
|
"""
|
||||||
|
if self.catastrophic_failure:
|
||||||
|
# Don't rely on any attributes being set if things failued
|
||||||
|
# catastrophically
|
||||||
|
raise SystemExit(True)
|
||||||
|
|
||||||
if self.options.count:
|
if self.options.count:
|
||||||
print(self.result_count)
|
print(self.result_count)
|
||||||
|
|
||||||
if self.options.exit_zero:
|
if self.options.exit_zero:
|
||||||
raise SystemExit(self.catastrophic_failure)
|
raise SystemExit(False)
|
||||||
else:
|
else:
|
||||||
raise SystemExit(
|
raise SystemExit(self.result_count > 0)
|
||||||
(self.result_count > 0) or self.catastrophic_failure
|
|
||||||
)
|
|
||||||
|
|
||||||
def find_plugins(self, config_finder):
|
def find_plugins(self, config_finder):
|
||||||
# type: (config.ConfigFileFinder) -> None
|
# type: (config.ConfigFileFinder) -> None
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,18 @@ def test_exit_does_raise(result_count, catastrophic, exit_zero, value,
|
||||||
assert excinfo.value.args[0] is value
|
assert excinfo.value.args[0] is value
|
||||||
|
|
||||||
|
|
||||||
|
def test_exit_raises(application):
|
||||||
|
"""Verify Application.exit raises SystemExit under configuration failure."""
|
||||||
|
application.catastrophic_failure = True
|
||||||
|
# Note: no application.options set -- configuration issues can lead to
|
||||||
|
# errors before it's assigned.
|
||||||
|
|
||||||
|
with pytest.raises(SystemExit) as excinfo:
|
||||||
|
application.exit()
|
||||||
|
|
||||||
|
assert excinfo.value.args[0] is True
|
||||||
|
|
||||||
|
|
||||||
def test_warns_on_unknown_formatter_plugin_name(application):
|
def test_warns_on_unknown_formatter_plugin_name(application):
|
||||||
"""Verify we log a warning with an unfound plugin."""
|
"""Verify we log a warning with an unfound plugin."""
|
||||||
default = mock.Mock()
|
default = mock.Mock()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue