summaryrefslogtreecommitdiff
blob: 0a8bb1eddc134806f9809190d5bc1e4fa3e4bba9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
Index: pychecker/pychecker/CodeChecks.py
===================================================================
--- pychecker.orig/pychecker/CodeChecks.py
+++ pychecker/pychecker/CodeChecks.py
@@ -144,7 +144,10 @@ def _checkBuiltin(code, loadValue, argCo
                 (func_name == 'getattr' and argCount == 2)):
                 arg2 = code.stack[-argCount + 1]
                 if arg2.const:
-                    code.addWarning(msgs.USES_CONST_ATTR % func_name)
+                    # lambda with setattr and const is a common way of setting
+                    # attributes, so allow it
+                    if code.func.function.func_name != '<lambda>':
+                        code.addWarning(msgs.USES_CONST_ATTR % func_name)
 
             if kwArgs:
                 _validateKwArgs(code, info, func_name, kwArgs)
@@ -395,7 +398,11 @@ def _handleFunctionCall(codeSource, code
                     name = utils.safestr(loadValue.data)
                     if type(loadValue.data) == types.TupleType :
                         name = string.join(loadValue.data, '.')
-                    code.addWarning(msgs.USING_NONE_RETURN_VALUE % name)
+                    # lambda with setattr is a common way of setting
+                    # attributes, so allow it
+                    if name != 'setattr' \
+                        or code.func.function.func_name != '<lambda>':
+                        code.addWarning(msgs.USING_NONE_RETURN_VALUE % name)
 
     code.stack = code.stack[:funcIndex] + [ returnValue ]
     code.functionsCalled[funcName] = loadValue