summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTorsten Marek <shlomme@gmail.com>2014-04-17 11:17:44 +0200
committerTorsten Marek <shlomme@gmail.com>2014-04-17 11:17:44 +0200
commit470132dbf57f63bc7c71dea1d7cdd47076f245d8 (patch)
tree920a17a3a03ac7f6133e6c00fbf956b8acc33964
parent55cee05bc4ad266e314610e35cf41eab55377e07 (diff)
downloadpylint-470132dbf57f63bc7c71dea1d7cdd47076f245d8.tar.gz
Only use and emit symbolic warnings in the main linter module
-rw-r--r--lint.py40
-rw-r--r--test/messages/func_i0011.txt2
-rw-r--r--test/messages/func_i0012.txt3
-rw-r--r--test/messages/func_i0020.txt2
-rw-r--r--test/messages/func_i0022.txt2
-rw-r--r--utils.py11
6 files changed, 30 insertions, 30 deletions
diff --git a/lint.py b/lint.py
index 5bafdc1..0cda818 100644
--- a/lint.py
+++ b/lint.py
@@ -109,11 +109,11 @@ MSGS = {
'Used when an inline option is either badly formatted or can\'t '
'be used inside modules.'),
- 'I0011': ('Locally disabling %s',
+ 'I0011': ('Locally disabling %s (%s)',
'locally-disabled',
'Used when an inline option disables a message or a messages '
'category.'),
- 'I0012': ('Locally enabling %s',
+ 'I0012': ('Locally enabling %s (%s)',
'locally-enabled',
'Used when an inline option enables a message or a messages '
'category.'),
@@ -473,14 +473,14 @@ warning, statement which respectively contain the number of errors / warnings\
if match.group(1).strip() == "disable-all" or \
match.group(1).strip() == 'skip-file':
if match.group(1).strip() == "disable-all":
- self.add_message('I0014', line=start[0])
- self.add_message('I0013', line=start[0])
+ self.add_message('deprecated-disable-all', line=start[0])
+ self.add_message('file-ignored', line=start[0])
self._ignore_file = True
return
try:
opt, value = match.group(1).split('=', 1)
except ValueError:
- self.add_message('I0010', args=match.group(1).strip(),
+ self.add_message('bad-inline-option', args=match.group(1).strip(),
line=start[0])
continue
opt = opt.strip()
@@ -494,15 +494,15 @@ warning, statement which respectively contain the number of errors / warnings\
for msgid in splitstrip(value):
try:
if (opt, msgid) == ('disable', 'all'):
- self.add_message('I0014', line=start[0])
- self.add_message('I0013', line=start[0])
+ self.add_message('deprecated-disable-all', line=start[0])
+ self.add_message('file-ignored', line=start[0])
self._ignore_file = True
return
meth(msgid, 'module', start[0])
except UnknownMessage:
- self.add_message('E0012', args=msgid, line=start[0])
+ self.add_message('bad-option-value', args=msgid, line=start[0])
else:
- self.add_message('E0011', args=opt, line=start[0])
+ self.add_message('unrecognized-inline-option', args=opt, line=start[0])
def collect_block_lines(self, node, msg_state):
"""walk ast to collect block level options line numbers"""
@@ -648,7 +648,7 @@ warning, statement which respectively contain the number of errors / warnings\
message = modname = error["mod"]
key = error["key"]
self.set_current_module(modname)
- if key == "F0001":
+ if key == "fatal":
message = str(error["ex"]).replace(os.getcwd() + os.sep, '')
self.add_message(key, args=message)
return result
@@ -679,13 +679,13 @@ warning, statement which respectively contain the number of errors / warnings\
try:
return MANAGER.ast_from_file(filepath, modname, source=True)
except SyntaxError, ex:
- self.add_message('E0001', line=ex.lineno, args=ex.msg)
+ self.add_message('syntax-error', line=ex.lineno, args=ex.msg)
except AstroidBuildingException, ex:
- self.add_message('F0010', args=ex)
+ self.add_message('parse-error', args=ex)
except Exception, ex:
import traceback
traceback.print_exc()
- self.add_message('F0002', args=(ex.__class__, ex))
+ self.add_message('astroid-error', args=(ex.__class__, ex))
def check_astroid_module(self, astroid, walker, rawcheckers, tokencheckers):
"""check a module from its astroid representation, real work"""
@@ -693,11 +693,11 @@ warning, statement which respectively contain the number of errors / warnings\
try:
tokens = tokenize_module(astroid)
except tokenize.TokenError, ex:
- self.add_message('E0001', line=ex.args[1][0], args=ex.args[0])
+ self.add_message('syntax-error', line=ex.args[1][0], args=ex.args[0])
return
if not astroid.pure_python:
- self.add_message('I0001', args=astroid.name)
+ self.add_message('raw-checker-failed', args=astroid.name)
else:
#assert astroid.file.endswith('.py')
# invoke ITokenChecker interface on self to fetch module/block
@@ -761,12 +761,12 @@ warning, statement which respectively contain the number of errors / warnings\
for warning, lines in self._raw_module_msgs_state.iteritems():
for line, enable in lines.iteritems():
if not enable and (warning, line) not in self._ignored_msgs:
- self.add_message('I0021', line, None,
+ self.add_message('useless-suppression', line, None,
(self.get_msg_display_string(warning),))
# don't use iteritems here, _ignored_msgs may be modified by add_message
for (warning, from_), lines in self._ignored_msgs.items():
for line in lines:
- self.add_message('I0020', line, None,
+ self.add_message('suppressed-message', line, None,
(self.get_msg_display_string(warning), from_))
def report_evaluation(self, sect, stats, previous_stats):
@@ -1013,9 +1013,9 @@ are done by default'''}),
'been issued by analysing pylint output status code\n',
level=1)
# read configuration
- linter.disable('W0704')
- linter.disable('I0020')
- linter.disable('I0021')
+ linter.disable('pointless-except')
+ linter.disable('suppressed-message')
+ linter.disable('useless-suppression')
linter.read_config_file()
# is there some additional plugins in the file configuration, in
config_parser = linter.cfgfile_parser
diff --git a/test/messages/func_i0011.txt b/test/messages/func_i0011.txt
index 87c1f1f..6c1071d 100644
--- a/test/messages/func_i0011.txt
+++ b/test/messages/func_i0011.txt
@@ -1,2 +1,2 @@
-I: 1: Locally disabling W0404
+I: 1: Locally disabling reimported (W0404)
I: 1: Useless suppression of 'reimported'
diff --git a/test/messages/func_i0012.txt b/test/messages/func_i0012.txt
index bf0c90f..76b0c77 100644
--- a/test/messages/func_i0012.txt
+++ b/test/messages/func_i0012.txt
@@ -1,2 +1 @@
-I: 1: Locally enabling W0404
-
+I: 1: Locally enabling reimported (W0404)
diff --git a/test/messages/func_i0020.txt b/test/messages/func_i0020.txt
index e25be4e..73f83a4 100644
--- a/test/messages/func_i0020.txt
+++ b/test/messages/func_i0020.txt
@@ -1,2 +1,2 @@
-I: 7: Locally disabling W0612
+I: 7: Locally disabling unused-variable (W0612)
I: 8: Suppressed 'unused-variable' (from line 7)
diff --git a/test/messages/func_i0022.txt b/test/messages/func_i0022.txt
index c882cae..471b8e3 100644
--- a/test/messages/func_i0022.txt
+++ b/test/messages/func_i0022.txt
@@ -1,4 +1,4 @@
-I: 5: Locally disabling C0103
+I: 5: Locally disabling invalid-name (C0103)
I: 5: Suppressed 'invalid-name' (from line 5)
I: 6: Deprecated pragma "pylint:disable-msg" or "pylint:enable-msg"
I: 6: Suppressed 'invalid-name' (from line 6)
diff --git a/utils.py b/utils.py
index 804229a..aee119e 100644
--- a/utils.py
+++ b/utils.py
@@ -286,8 +286,9 @@ class MessagesHandlerMixIn(object):
self._module_msgs_state[msg.msgid][line] = False
except KeyError:
self._module_msgs_state[msg.msgid] = {line: False}
- if msgid != 'I0011':
- self.add_message('I0011', line=line, args=msg.msgid)
+ if msg.symbol != 'locally-disabled':
+ self.add_message('locally-disabled', line=line,
+ args=(msg.symbol, msg.msgid))
else:
msgs = self._msgs_state
@@ -330,7 +331,7 @@ class MessagesHandlerMixIn(object):
self._module_msgs_state[msg.msgid][line] = True
except KeyError:
self._module_msgs_state[msg.msgid] = {line: True}
- self.add_message('I0012', line=line, args=msg.msgid)
+ self.add_message('locally-enabled', line=line, args=(msg.symbol, msg.msgid))
else:
msgs = self._msgs_state
msgs[msg.msgid] = True
@@ -629,12 +630,12 @@ def expand_modules(files_or_modules, black_list):
try:
filepath = file_from_modpath(modname.split('.'))
if filepath is None:
- errors.append({'key' : 'F0003', 'mod': modname})
+ errors.append({'key' : 'ignored-builtin-module', 'mod': modname})
continue
except (ImportError, SyntaxError), ex:
# FIXME p3k : the SyntaxError is a Python bug and should be
# removed as soon as possible http://bugs.python.org/issue10588
- errors.append({'key': 'F0001', 'mod': modname, 'ex': ex})
+ errors.append({'key': 'fatal', 'mod': modname, 'ex': ex})
continue
filepath = normpath(filepath)
result.append({'path': filepath, 'name': modname,