Patchwork [1,of,5,V2] check-code: allow assignment to hasattr variable

login
register
mail settings
Submitter Yuya Nishihara
Date Aug. 16, 2016, 8:50 a.m.
Message ID <2a4b9fa66b0b568c50e2.1471337442@mimosa>
Download mbox | patch
Permalink /patch/16318/
State Accepted
Headers show

Comments

Yuya Nishihara - Aug. 16, 2016, 8:50 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1471335354 -32400
#      Tue Aug 16 17:15:54 2016 +0900
# Node ID 2a4b9fa66b0b568c50e2069b44cf01ea79eba6df
# Parent  780d6b210b5fb0087a532aee0583f4d23af1f1d6
check-code: allow assignment to hasattr variable

Patch

diff --git a/contrib/check-code.py b/contrib/check-code.py
--- a/contrib/check-code.py
+++ b/contrib/check-code.py
@@ -295,7 +295,7 @@  pypats = [
      "comparison with singleton, use 'is' or 'is not' instead"),
     (r'^\s*(while|if) [01]:',
      "use True/False for constant Boolean expression"),
-    (r'(?:(?<!def)\s+|\()hasattr',
+    (r'(?:(?<!def)\s+|\()hasattr\(',
      'hasattr(foo, bar) is broken, use util.safehasattr(foo, bar) instead'),
     (r'opener\([^)]*\).read\(',
      "use opener.read() instead"),