Skip to content

Commit

Permalink
bpo-36853: Fix suspicious.py to actually print the unused rules (#13579)
Browse files Browse the repository at this point in the history
* Fix suspicious.py to actually print the unused rules

* Fix the other `self.warn` calls
  • Loading branch information
asottile authored and jaraco committed Sep 2, 2019
1 parent 102e9b4 commit e1786b5
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions Doc/tools/extensions/suspicious.py
Expand Up @@ -115,10 +115,12 @@ def write_doc(self, docname, doctree):
def finish(self):
unused_rules = [rule for rule in self.rules if not rule.used]
if unused_rules:
self.logger.warn('Found %s/%s unused rules:' %
(len(unused_rules), len(self.rules)))
for rule in unused_rules:
self.logger.info(repr(rule))
self.logger.warning(
'Found %s/%s unused rules: %s' % (
len(unused_rules), len(self.rules),
''.join(repr(rule) for rule in unused_rules),
)
)
return

def check_issue(self, line, lineno, issue):
Expand Down Expand Up @@ -151,14 +153,15 @@ def report_issue(self, text, lineno, issue):
self.any_issue = True
self.write_log_entry(lineno, issue, text)
if py3:
self.logger.warn('[%s:%d] "%s" found in "%-.120s"' %
(self.docname, lineno, issue, text))
self.logger.warning('[%s:%d] "%s" found in "%-.120s"' %
(self.docname, lineno, issue, text))
else:
self.logger.warn('[%s:%d] "%s" found in "%-.120s"' % (
self.docname.encode(sys.getdefaultencoding(),'replace'),
lineno,
issue.encode(sys.getdefaultencoding(),'replace'),
text.strip().encode(sys.getdefaultencoding(),'replace')))
self.logger.warning(
'[%s:%d] "%s" found in "%-.120s"' % (
self.docname.encode(sys.getdefaultencoding(),'replace'),
lineno,
issue.encode(sys.getdefaultencoding(),'replace'),
text.strip().encode(sys.getdefaultencoding(),'replace')))
self.app.statuscode = 1

def write_log_entry(self, lineno, issue, text):
Expand Down

0 comments on commit e1786b5

Please sign in to comment.