Skip to content

Commit

Permalink
Rename UnknownMessage, EmptyReport to UnknownMessageError, EmptyRepor…
Browse files Browse the repository at this point in the history
…tError
  • Loading branch information
glennmatthews committed Jul 19, 2016
1 parent 0495355 commit f63f165
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 25 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ Release date: tba
* InvalidMessageError, UnknownMessage, and EmptyReport exceptions are
moved to the new pylint.exceptions submodule.

* UnknownMessage and EmptyReport are renamed to UnknownMessageError and
EmptyReportError.

What's new in Pylint 1.6.3?
===========================

Expand Down
3 changes: 2 additions & 1 deletion doc/whatsnew/2.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ Other Changes
* Add ``InvalidMessageError`` exception class and replace ``assert`` in
pylint.utils with ``raise InvalidMessageError``.

* ``UnknownMessage`` and ``EmptyReport`` are now provided by the new
* ``UnknownMessageError`` (formerly ``UnknownMessage``) and
``EmptyReportError`` (formerly ``EmptyReport``) are now provided by the new
``pylint.exceptions`` submodule instead of ``pylint.utils`` as before.

Bug fixes
Expand Down
4 changes: 2 additions & 2 deletions pylint/checkers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

from pylint.interfaces import (IAstroidChecker, ITokenChecker, INFERENCE,
INFERENCE_FAILURE, HIGH)
from pylint.exceptions import EmptyReport
from pylint.exceptions import EmptyReportError
from pylint.reporters import diff_string
from pylint.checkers import BaseChecker, BaseTokenChecker
from pylint.checkers.utils import (
Expand Down Expand Up @@ -228,7 +228,7 @@ def report_by_type_stats(sect, stats, old_stats):
try:
total = stats[node_type]
except KeyError:
raise EmptyReport()
raise EmptyReportError()
nice_stats[node_type] = {}
if total != 0:
try:
Expand Down
6 changes: 3 additions & 3 deletions pylint/checkers/imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

from pylint.interfaces import IAstroidChecker
from pylint.utils import get_global_option
from pylint.exceptions import EmptyReport
from pylint.exceptions import EmptyReportError
from pylint.checkers import BaseChecker
from pylint.checkers.utils import (
check_messages,
Expand Down Expand Up @@ -673,7 +673,7 @@ def _report_external_dependencies(self, sect, _, _dummy):
"""return a verbatim layout for displaying dependencies"""
dep_info = _make_tree_defs(six.iteritems(self._external_dependencies_info()))
if not dep_info:
raise EmptyReport()
raise EmptyReportError()
tree_str = _repr_tree_defs(dep_info)
sect.append(VerbatimText(tree_str))

Expand All @@ -683,7 +683,7 @@ def _report_dependencies_graph(self, sect, _, _dummy):
if not dep_info or not (self.config.import_graph
or self.config.ext_import_graph
or self.config.int_import_graph):
raise EmptyReport()
raise EmptyReportError()
filename = self.config.import_graph
if filename:
_make_graph(filename, dep_info, sect, '')
Expand Down
4 changes: 2 additions & 2 deletions pylint/checkers/raw_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import tokenize

from pylint.interfaces import ITokenChecker
from pylint.exceptions import EmptyReport
from pylint.exceptions import EmptyReportError
from pylint.checkers import BaseTokenChecker
from pylint.reporters import diff_string
from pylint.reporters.ureports.nodes import Table
Expand All @@ -23,7 +23,7 @@ def report_raw_stats(sect, stats, old_stats):
"""
total_lines = stats['total_lines']
if not total_lines:
raise EmptyReport()
raise EmptyReportError()
sect.description = '%s lines have been analyzed' % total_lines
lines = ('type', 'number', '%', 'previous', 'difference')
for node_type in ('code', 'docstring', 'comment', 'empty'):
Expand Down
4 changes: 2 additions & 2 deletions pylint/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
class InvalidMessageError(Exception):
"""raised when a message creation, registration or addition is rejected"""

class UnknownMessage(Exception):
class UnknownMessageError(Exception):
"""raised when a unregistered message id is encountered"""

class EmptyReport(Exception):
class EmptyReportError(Exception):
"""raised when a report is empty and so should not be displayed"""
8 changes: 4 additions & 4 deletions pylint/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ def process_tokens(self, tokens):
self._ignore_file = True
return
meth(msgid, 'module', start[0])
except exceptions.UnknownMessage:
except exceptions.UnknownMessageError:
self.add_message('bad-option-value', args=msgid, line=start[0])
else:
self.add_message('unrecognized-inline-option', args=opt, line=start[0])
Expand Down Expand Up @@ -996,7 +996,7 @@ def report_messages_stats(sect, stats, _):
"""make messages type report"""
if not stats['by_msg']:
# don't print this report when we didn't detected any errors
raise exceptions.EmptyReport()
raise exceptions.EmptyReportError()
in_order = sorted([(value, msg_id)
for msg_id, value in six.iteritems(stats['by_msg'])
if not msg_id.startswith('I')])
Expand All @@ -1010,7 +1010,7 @@ def report_messages_by_module_stats(sect, stats, _):
"""make errors / warnings by modules report"""
if len(stats['by_module']) == 1:
# don't print this report when we are analysing a single module
raise exceptions.EmptyReport()
raise exceptions.EmptyReportError()
by_mod = collections.defaultdict(dict)
for m_type in ('fatal', 'error', 'warning', 'refactor', 'convention'):
total = stats[m_type]
Expand Down Expand Up @@ -1039,7 +1039,7 @@ def report_messages_by_module_stats(sect, stats, _):
for val in line[:-1]:
lines.append('%.2f' % val)
if len(lines) == 5:
raise exceptions.EmptyReport()
raise exceptions.EmptyReportError()
sect.append(report_nodes.Table(children=lines, cols=5, rheaders=1))


Expand Down
4 changes: 2 additions & 2 deletions pylint/test/unittest_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from pylint.utils import MSG_STATE_SCOPE_CONFIG, MSG_STATE_SCOPE_MODULE, MSG_STATE_CONFIDENCE, \
MessagesStore, PyLintASTWalker, MessageDefinition, FileState, \
build_message_def, tokenize_module
from pylint.exceptions import InvalidMessageError, UnknownMessage
from pylint.exceptions import InvalidMessageError, UnknownMessageError
from pylint.testutils import TestReporter
from pylint.reporters import text
from pylint import checkers
Expand Down Expand Up @@ -636,7 +636,7 @@ def _compare_messages(self, desc, msg, checkerref=False):
def test_check_message_id(self):
self.assertIsInstance(self.store.check_message_id('W1234'),
MessageDefinition)
self.assertRaises(UnknownMessage,
self.assertRaises(UnknownMessageError,
self.store.check_message_id, 'YB12')

def test_message_help(self):
Expand Down
18 changes: 9 additions & 9 deletions pylint/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

from pylint.interfaces import IRawChecker, ITokenChecker, UNDEFINED, implements
from pylint.reporters.ureports.nodes import Section
from pylint.exceptions import InvalidMessageError, UnknownMessage, EmptyReport
from pylint.exceptions import InvalidMessageError, UnknownMessageError, EmptyReportError


MSG_TYPES = {
Expand Down Expand Up @@ -246,7 +246,7 @@ def disable(self, msgid, scope='package', line=None, ignore_unknown=False):
try:
# msgid is a symbolic or numeric msgid.
msg = self.msgs_store.check_message_id(msgid)
except UnknownMessage:
except UnknownMessageError:
if ignore_unknown:
return
raise
Expand All @@ -273,7 +273,7 @@ def _message_symbol(self, msgid):
"""
try:
return self.msgs_store.check_message_id(msgid).symbol
except UnknownMessage:
except UnknownMessageError:
return msgid

def enable(self, msgid, scope='package', line=None, ignore_unknown=False):
Expand Down Expand Up @@ -307,7 +307,7 @@ def enable(self, msgid, scope='package', line=None, ignore_unknown=False):
try:
# msgid is a symbolic or numeric msgid.
msg = self.msgs_store.check_message_id(msgid)
except UnknownMessage:
except UnknownMessageError:
if ignore_unknown:
return
raise
Expand Down Expand Up @@ -342,7 +342,7 @@ def is_message_enabled(self, msg_descr, line=None, confidence=None):
return False
try:
msgid = self.msgs_store.check_message_id(msg_descr).msgid
except UnknownMessage:
except UnknownMessageError:
# The linter checks for messages that are not registered
# due to version mismatch, just treat them as message IDs
# for now.
Expand Down Expand Up @@ -720,7 +720,7 @@ def check_message_id(self, msgid):
msgid may be either a numeric or symbolic id.
Raises UnknownMessage if the message id is not defined.
Raises UnknownMessageError if the message id is not defined.
"""
if msgid[1:].isdigit():
msgid = msgid.upper()
Expand All @@ -729,7 +729,7 @@ def check_message_id(self, msgid):
return source[msgid]
except KeyError:
pass
raise UnknownMessage('No such message id %s' % msgid)
raise UnknownMessageError('No such message id %s' % msgid)

def get_msg_display_string(self, msgid):
"""Generates a user-consumable representation of a message.
Expand All @@ -744,7 +744,7 @@ def help_message(self, msgids):
try:
print(self.check_message_id(msgid).format_help(checkerref=True))
print("")
except UnknownMessage as ex:
except UnknownMessageError as ex:
print(ex)
print("")
continue
Expand Down Expand Up @@ -811,7 +811,7 @@ def make_reports(self, stats, old_stats):
report_sect = Section(r_title)
try:
r_cb(report_sect, stats, old_stats)
except EmptyReport:
except EmptyReportError:
continue
report_sect.report_id = reportid
sect.append(report_sect)
Expand Down

0 comments on commit f63f165

Please sign in to comment.