Patchwork [2,of,2] check-code: look for misuse of __bool__

login
register
mail settings
Submitter Yuya Nishihara
Date Sept. 16, 2014, 3:59 p.m.
Message ID <161fd3b412acce6ff0d3.1410883167@mimosa>
Download mbox | patch
Permalink /patch/5830/
State Accepted
Headers show

Comments

Yuya Nishihara - Sept. 16, 2014, 3:59 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1410881317 -32400
#      Wed Sep 17 00:28:37 2014 +0900
# Node ID 161fd3b412acce6ff0d364d41618bd1a627b3877
# Parent  41ce9361751ce40497dcbf29ec2d84ef0fbc7593
check-code: look for misuse of __bool__
Matt Mackall - Sept. 16, 2014, 4:32 p.m.
On Wed, 2014-09-17 at 00:59 +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1410881317 -32400
> #      Wed Sep 17 00:28:37 2014 +0900
> # Node ID 161fd3b412acce6ff0d364d41618bd1a627b3877
> # Parent  41ce9361751ce40497dcbf29ec2d84ef0fbc7593
> check-code: look for misuse of __bool__

These are queued, thanks.

Patch

diff --git a/contrib/check-code.py b/contrib/check-code.py
--- a/contrib/check-code.py
+++ b/contrib/check-code.py
@@ -299,6 +299,7 @@  pypats = [
     (r'ui\.(status|progress|write|note|warn)\([\'\"]x',
      "missing _() in ui message (use () to hide false-positives)"),
     (r'release\(.*wlock, .*lock\)', "wrong lock release order"),
+    (r'\b__bool__\b', "__bool__ should be __nonzero__ in Python 2"),
   ],
   # warnings
   [