jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/236495 )
Change subject: Enable hacking rule H201 ...................................................................... Enable hacking rule H201 Prevent use of `except:`; require `except Exception:` or a more specific exception class. Signed-off-by: xqt <[email protected]> Change-Id: Ie71c2062d9cf04715fa76da500d55a6103726fbd --- M generate_user_files.py M pywikibot/config2.py M pywikibot/data/api.py M pywikibot/pagegenerators.py M scripts/script_wui.py M tox.ini 6 files changed, 10 insertions(+), 11 deletions(-) Approvals: jenkins-bot: Verified Xqt: Looks good to me, approved diff --git a/generate_user_files.py b/generate_user_files.py index faf7cda..92bd19e 100755 --- a/generate_user_files.py +++ b/generate_user_files.py @@ -295,11 +295,9 @@ config_text=config_text)) pywikibot.output(u"'%s' written." % _fnc) - except Exception: - try: + except BaseException: + if os.path.exists(_fnc): os.remove(_fnc) - except Exception: - pass raise diff --git a/pywikibot/config2.py b/pywikibot/config2.py index e42c75c..f19f37b 100644 --- a/pywikibot/config2.py +++ b/pywikibot/config2.py @@ -418,7 +418,7 @@ console_encoding = sys.stdout.encoding else: console_encoding = sys.stdout.encoding.decode('ascii') -except Exception: +except AttributeError: # When using pywikibot inside a daemonized twisted application, # we get "StdioOnnaStick instance has no attribute 'encoding'" console_encoding = None @@ -474,7 +474,9 @@ try: # Don't print colorized when the output is, for example, piped to a file. colorized_output = sys.stdout.isatty() -except Exception: +except AttributeError: + # When using pywikibot inside a daemonized twisted application, + # we get "StdioOnnaStick instance has no attribute 'isatty'" colorized_output = False # An indication of the size of your screen, or rather the size of the screen diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py index cdbcfea..9e2627d 100644 --- a/pywikibot/data/api.py +++ b/pywikibot/data/api.py @@ -1998,7 +1998,7 @@ self._params[param] = [str(int(value) // 2)] pywikibot.output(u"Set %s = %s" % (param, self._params[param])) - except Exception: + except ValueError: pass self.wait() continue diff --git a/pywikibot/pagegenerators.py b/pywikibot/pagegenerators.py index 0389c7c..4c5addc 100644 --- a/pywikibot/pagegenerators.py +++ b/pywikibot/pagegenerators.py @@ -1008,7 +1008,7 @@ if value: try: total = int(value) - except Exception: + except ValueError: params = value.split(';') if len(params) == 2: value, total = params diff --git a/scripts/script_wui.py b/scripts/script_wui.py index 9fadbeb..5e61c61 100755 --- a/scripts/script_wui.py +++ b/scripts/script_wui.py @@ -355,7 +355,7 @@ bot = ScriptWUIBot(site, chan, site.user() + "_WUI", "irc.wikimedia.org") try: bot.start() - except Exception: + except BaseException: bot.t.cancel() raise diff --git a/tox.ini b/tox.ini index a378065..4221381 100644 --- a/tox.ini +++ b/tox.ini @@ -151,7 +151,6 @@ # D102: Missing docstring in public method # D103: Missing docstring in public function # E402: module level import not at top of file; see T87409 -# H201: Except: format # N802, N803, N806 : naming convention # P102,P103: string does contain unindexed parameters; see I36355923 @@ -160,7 +159,7 @@ # D413: Missing blank line after last section # D412: No blank lines allowed between a section header and its content -ignore = C401,C402,C405,E402,D105,D211,FI10,FI12,FI13,FI15,FI16,FI17,FI5,H101,H201,H236,H301,H404,H405,H903,I100,I101,I202,N802,N803,N806,D401,D413,D103,D412 +ignore = C401,C402,C405,E402,D105,D211,FI10,FI12,FI13,FI15,FI16,FI17,FI5,H101,H236,H301,H404,H405,H903,I100,I101,I202,N802,N803,N806,D401,D413,D103,D412 exclude = .tox,.git,./*.egg,ez_setup.py,build,externals,user-config.py,./scripts/i18n/* min-version = 2.6 max_line_length = 100 -- To view, visit https://gerrit.wikimedia.org/r/236495 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ie71c2062d9cf04715fa76da500d55a6103726fbd Gerrit-PatchSet: 10 Gerrit-Project: pywikibot/core Gerrit-Branch: master Gerrit-Owner: John Vandenberg <[email protected]> Gerrit-Reviewer: John Vandenberg <[email protected]> Gerrit-Reviewer: XZise <[email protected]> Gerrit-Reviewer: Xqt <[email protected]> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
