summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSylvain Th?nault <sylvain.thenault@logilab.fr>2009-11-25 18:13:19 +0100
committerSylvain Th?nault <sylvain.thenault@logilab.fr>2009-11-25 18:13:19 +0100
commit965ff2408eb111532b1babfcd0b71724ce5f1202 (patch)
tree8532a38723bf3e813d8810a6cfbddb6935ac19c8
parent20c69939196c25a7961e9fd6bd4cbd19d9e409fd (diff)
parent372671c91522060fe98c5be1a9c4832328a3189b (diff)
downloadpylint-965ff2408eb111532b1babfcd0b71724ce5f1202.tar.gz
merge
-rw-r--r--checkers/typecheck.py4
-rw-r--r--checkers/utils.py8
-rw-r--r--lint.py15
-rw-r--r--test/test_func.py25
-rw-r--r--utils.py28
5 files changed, 64 insertions, 16 deletions
diff --git a/checkers/typecheck.py b/checkers/typecheck.py
index ab04843..49e595d 100644
--- a/checkers/typecheck.py
+++ b/checkers/typecheck.py
@@ -25,7 +25,7 @@ from logilab.astng.infutils import YES, Instance
from pylint.interfaces import IASTNGChecker
from pylint.checkers import BaseChecker
-from pylint.checkers.utils import safe_infer, is_super, display_type
+from pylint.checkers.utils import safe_infer, is_super
MSGS = {
'E1101': ('%s %r has no %r member',
@@ -187,7 +187,7 @@ accessed.'}
else:
msgid = 'E1101'
self.add_message(msgid, node=node,
- args=(display_type(owner), name,
+ args=(owner.display_type(), name,
node.attrname))
diff --git a/checkers/utils.py b/checkers/utils.py
index ba371a5..508fb06 100644
--- a/checkers/utils.py
+++ b/checkers/utils.py
@@ -182,14 +182,6 @@ def overrides_a_method(class_node, name):
return True
return False
-def display_type(node):
- """return the type of this node for screen display"""
- if isinstance(node, astng.Instance):
- return 'Instance of'
- elif isinstance(node, astng.Module):
- return 'Module'
- return 'Class'
-
PYMETHODS = set(('__new__', '__init__', '__del__', '__hash__',
'__str__', '__repr__',
'__len__', '__iter__',
diff --git a/lint.py b/lint.py
index 8c7ef19..3015579 100644
--- a/lint.py
+++ b/lint.py
@@ -787,6 +787,12 @@ exit. The value may be a comma separated list of message ids.'''}),
{'action' : 'callback', 'metavar': '<msg-id>',
'callback' : self.cb_list_messages,
'group': 'Commands',
+ 'help' : "Generate pylint's messages."}),
+
+ ('full-documentation',
+ {'action' : 'callback', 'metavar': '<msg-id>',
+ 'callback' : self.cb_full_documentation,
+ 'group': 'Commands',
'help' : "Generate pylint's full documentation."}),
('generate-rcfile',
@@ -922,9 +928,14 @@ been issued by analysing pylint output status code
self.linter.help_message(splitstrip(value))
sys.exit(0)
- def cb_list_messages(self, option, opt_name, value, parser):
+ def cb_full_documentation(self, option, opt_name, value, parser):
+ """optik callback for printing full documentation"""
+ self.linter.print_full_documentation()
+ sys.exit(0)
+
+ def cb_list_messages(self, option, opt_name, value, parser): # FIXME
"""optik callback for printing available messages"""
- self.linter.list_messages()
+ self.linter.list_sorted_messages()
sys.exit(0)
def cb_init_hook(option, opt_name, value, parser):
diff --git a/test/test_func.py b/test/test_func.py
index e614d5c..1d0494d 100644
--- a/test/test_func.py
+++ b/test/test_func.py
@@ -57,10 +57,29 @@ def exception_str(ex):
return 'in %s\n:: %s' % (ex.file, ', '.join(ex.args))
class LintTestUsingModule(testlib.TestCase):
- package = 'input'
+ DEFAULT_PACKAGE = 'input'
+ package = DEFAULT_PACKAGE
linter = linter
+ module = None
+ depends = None
+
+ _TEST_TYPE = 'module'
+
+ def shortDescription(self):
+ values = { 'mode' : self._TEST_TYPE,
+ 'input': self.module,
+ 'pkg': self.package,
+ 'cls': self.__class__.__name__}
+
+ if self.package == self.DEFAULT_PACKAGE:
+ msg = '%(mode)s test of input file "%(input)s" (%(cls)s)'
+ else:
+ msg = '%(mode)s test of input file "%(input)s" in "%(pkg)s" (%(cls)s)'
+ return msg % values
+
def setUp(self):
MANAGER.set_cache_size(200) # reset cache
+
def test_functionality(self):
tocheck = [self.package+'.'+self.module]
if self.depends:
@@ -98,6 +117,8 @@ class LintTestUsingModule(testlib.TestCase):
class LintTestUsingFile(LintTestUsingModule):
+ _TEST_TYPE = 'file'
+
def test_functionality(self):
tocheck = [self.package+'/' + self.module + '.py']
if self.depends:
@@ -168,6 +189,7 @@ def make_tests(filter_rgx):
module = module_file.replace('.py', '')
output = messages_file
depends = dependencies or None
+ tags = testlib.Tags(('generated',))
tests.append(LintTestUsingModuleTC)
if MODULES_ONLY:
@@ -177,6 +199,7 @@ def make_tests(filter_rgx):
module = module_file.replace('.py', '')
output = exists(messages_file + '2') and (messages_file + '2') or messages_file
depends = dependencies or None
+ tags = testlib.Tags(('generated',))
tests.append(LintTestUsingFileTC)
## # special test for f0003
diff --git a/utils.py b/utils.py
index a91d8c6..06b2ba4 100644
--- a/utils.py
+++ b/utils.py
@@ -279,7 +279,12 @@ class MessagesHandlerMixIn:
print
continue
- def list_messages(self):
+ def list_checkers_messages(self, checker):
+ """print checker's messages in reST format"""
+ for msg_id in sort_msgs(checker.msgs.keys()):
+ print self.get_message_help(msg_id, False)
+
+ def print_full_documentation(self):
"""output a full documentation in ReST format"""
for checker in sort_checkers(self._checkers.values()):
if checker.name == 'master':
@@ -313,8 +318,7 @@ class MessagesHandlerMixIn:
title = ('%smessages' % prefix).capitalize()
print title
print '~' * len(title)
- for msg_id in sort_msgs(checker.msgs.keys()):
- print self.get_message_help(msg_id, False)
+ self.list_checkers_messages( checker)
print
if getattr(checker, 'reports', None):
title = ('%sreports' % prefix).capitalize()
@@ -325,6 +329,24 @@ class MessagesHandlerMixIn:
print
print
+ def list_messages(self):
+ """output full messages list documentation in ReST format"""
+ for checker in sort_checkers(self._checkers.values()):
+ if checker.msgs:
+ self.list_checkers_messages( checker)
+ print
+
+ def list_sorted_messages(self):
+ """output full sorted messages list in ReST format"""
+ msg_ids = []
+ for checker in self._checkers.values():
+ for msg_id in checker.msgs.keys():
+ msg_ids.append(msg_id)
+ msg_ids.sort()
+ for msg_id in msg_ids:
+ print self.get_message_help(msg_id, False)
+ print
+
class ReportsHandlerMixIn:
"""a mix-in class containing all the reports and stats manipulation