[Python-checkins] bpo-36853: Fix suspicious.py to actually print the unused rules (#13579) (#15653)

Jason R. Coombs webhook-mailer at python.org
Mon Sep 2 15:17:29 EDT 2019


https://github.com/python/cpython/commit/ebe709dc1d7c1f9f07dc7d77e53674d2500b223e
commit: ebe709dc1d7c1f9f07dc7d77e53674d2500b223e
branch: 3.7
author: Anthony Sottile <asottile at umich.edu>
committer: Jason R. Coombs <jaraco at jaraco.com>
date: 2019-09-02T15:17:18-04:00
summary:

bpo-36853: Fix suspicious.py to actually print the unused rules (#13579) (#15653)

* Fix suspicious.py to actually print the unused rules

* Fix the other `self.warn` calls

(cherry picked from commit e1786b54162e2bfb01ca5aafa19d596c4af5a803)

files:
M Doc/tools/extensions/suspicious.py

diff --git a/Doc/tools/extensions/suspicious.py b/Doc/tools/extensions/suspicious.py
index 8d80f6759bff..fd50f318170b 100644
--- a/Doc/tools/extensions/suspicious.py
+++ b/Doc/tools/extensions/suspicious.py
@@ -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.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):
@@ -152,14 +154,15 @@ def report_issue(self, text, lineno, issue):
         self.any_issue = True
         self.write_log_entry(lineno, issue, text)
         if py3:
-            self.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.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):



More information about the Python-checkins mailing list