fix unnecessary lambda and enable corresponding pylint check
authorAndrey Skvortsov <andrej.skvortzov@gmail.com>
Thu, 28 Sep 2017 16:25:05 +0300
changeset 1833 2269739dd098
parent 1832 0f1081928d65
child 1834 cd42b426028b
fix unnecessary lambda and enable corresponding pylint check
ConfigTreeNode.py
connectors/PYRO/__init__.py
controls/VariablePanel.py
dialogs/ArrayTypeDialog.py
editors/DataTypeEditor.py
editors/TextViewer.py
py_ext/PythonFileCTNMixin.py
svgui/svgui.py
tests/tools/check_source.sh
--- a/ConfigTreeNode.py	Thu Sep 28 15:17:57 2017 +0300
+++ b/ConfigTreeNode.py	Thu Sep 28 16:25:05 2017 +0300
@@ -258,7 +258,7 @@
             }, ...]
         @return: [(C_file_name, CFLAGS),...] , LDFLAGS_TO_APPEND
         """
-        self.GetCTRoot().logger.write_warning(".".join(map(lambda x: str(x), self.GetCurrentLocation())) + " -> Nothing to do\n")
+        self.GetCTRoot().logger.write_warning(".".join(map(str, self.GetCurrentLocation())) + " -> Nothing to do\n")
         return [], "", False
 
     def _Generate_C(self, buildpath, locations):
--- a/connectors/PYRO/__init__.py	Thu Sep 28 15:17:57 2017 +0300
+++ b/connectors/PYRO/__init__.py	Thu Sep 28 16:25:05 2017 +0300
@@ -134,7 +134,7 @@
 
     # Check connection is effective.
     # lambda is for getattr of GetPLCstatus to happen inside catcher
-    if PyroCatcher(lambda: RemotePLCObjectProxy.GetPLCstatus())() is None:
+    if PyroCatcher(RemotePLCObjectProxy.GetPLCstatus)() is None:
         confnodesroot.logger.write_error(_("Cannot get PLC status - connection failed.\n"))
         return None
 
--- a/controls/VariablePanel.py	Thu Sep 28 15:17:57 2017 +0300
+++ b/controls/VariablePanel.py	Thu Sep 28 16:25:05 2017 +0300
@@ -140,7 +140,7 @@
             value = getattr(self.data[row], colname, "")
             if colname == "Type" and isinstance(value, TupleType):
                 if value[0] == "array":
-                    return "ARRAY [%s] OF %s" % (",".join(map(lambda x: "..".join(x), value[2])), value[1])
+                    return "ARRAY [%s] OF %s" % (",".join(map("..".join, value[2])), value[1])
             if not isinstance(value, (StringType, UnicodeType)):
                 value = str(value)
             if colname in ["Class", "Option"]:
--- a/dialogs/ArrayTypeDialog.py	Thu Sep 28 15:17:57 2017 +0300
+++ b/dialogs/ArrayTypeDialog.py	Thu Sep 28 16:25:05 2017 +0300
@@ -83,7 +83,7 @@
 
         if isinstance(infos, TupleType) and infos[0] == "array":
             self.BaseType.SetStringSelection(infos[1])
-            self.Dimensions.SetStrings(map(lambda x: "..".join(x), infos[2]))
+            self.Dimensions.SetStrings(map("..".join, infos[2]))
         elif infos in datatypes:
             self.BaseType.SetStringSelection(infos)
 
--- a/editors/DataTypeEditor.py	Thu Sep 28 15:17:57 2017 +0300
+++ b/editors/DataTypeEditor.py	Thu Sep 28 16:25:05 2017 +0300
@@ -82,7 +82,7 @@
 
             if colname == "Type" and isinstance(value, TupleType):
                 if value[0] == "array":
-                    return "ARRAY [%s] OF %s" % (",".join(map(lambda x: "..".join(x), value[2])), value[1])
+                    return "ARRAY [%s] OF %s" % (",".join(map("..".join, value[2])), value[1])
             return value
 
     def SetValue(self, row, col, value):
@@ -510,7 +510,7 @@
                 self.EnumeratedInitialValue.SetStringSelection(type_infos["initial"])
             elif type_infos["type"] == "Array":
                 self.ArrayBaseType.SetStringSelection(type_infos["base_type"])
-                self.ArrayDimensions.SetStrings(map(lambda x: "..".join(x), type_infos["dimensions"]))
+                self.ArrayDimensions.SetStrings(map("..".join, type_infos["dimensions"]))
                 self.ArrayInitialValue.SetValue(type_infos["initial"])
             elif type_infos["type"] == "Structure":
                 self.StructureElementsTable.SetData(type_infos["elements"])
--- a/editors/TextViewer.py	Thu Sep 28 15:17:57 2017 +0300
+++ b/editors/TextViewer.py	Thu Sep 28 16:25:05 2017 +0300
@@ -70,7 +70,7 @@
 
 
 def LineStartswith(line, symbols):
-    return reduce(lambda x, y: x or y, map(lambda x: line.startswith(x), symbols), False)
+    return reduce(lambda x, y: x or y, map(line.startswith, symbols), False)
 
 
 class TextViewer(EditorPanel):
--- a/py_ext/PythonFileCTNMixin.py	Thu Sep 28 15:17:57 2017 +0300
+++ b/py_ext/PythonFileCTNMixin.py	Thu Sep 28 16:25:05 2017 +0300
@@ -95,8 +95,7 @@
 
     def CTNGenerate_C(self, buildpath, locations):
         # location string for that CTN
-        location_str = "_".join(map(lambda x: str(x),
-                                self.GetCurrentLocation()))
+        location_str = "_".join(map(str, self.GetCurrentLocation()))
         configname = self.GetCTRoot().GetProjectConfigNames()[0]
 
         pyextname = self.CTNName()
--- a/svgui/svgui.py	Thu Sep 28 15:17:57 2017 +0300
+++ b/svgui/svgui.py	Thu Sep 28 16:25:05 2017 +0300
@@ -86,7 +86,7 @@
 
         current_location = self.GetCurrentLocation()
         # define a unique name for the generated C file
-        location_str = "_".join(map(lambda x: str(x), current_location))
+        location_str = "_".join(map(str, current_location))
 
         res = ([], "", False)
 
--- a/tests/tools/check_source.sh	Thu Sep 28 15:17:57 2017 +0300
+++ b/tests/tools/check_source.sh	Thu Sep 28 16:25:05 2017 +0300
@@ -192,19 +192,21 @@
     export PYTHONPATH="$PWD/../CanFestival-3/objdictgen":$PYTHONPATH
 
     disable=
-    disable=$disable,C0103 # invalid-name
-    disable=$disable,C0111 # missing-docstring
-    disable=$disable,W0703 # broad-except
-    disable=$disable,C0326 # bad whitespace
-    disable=$disable,C0301 # Line too long
-    disable=$disable,C0302 # Too many lines in module
-    disable=$disable,W0511 # fixme
+    disable=$disable,C0103        # invalid-name
+    disable=$disable,C0111        # missing-docstring
+    disable=$disable,W0703        # broad-except
+    disable=$disable,C0326        # bad whitespace
+    disable=$disable,C0301        # Line too long
+    disable=$disable,C0302        # Too many lines in module
+    disable=$disable,W0511        # fixme
+    disable=$disable,W0110        # (deprecated-lambda) map/filter on lambda could be replaced by comprehension
 
     enable=
     enable=$enable,E1601          # print statement used
     enable=$enable,C0325          # (superfluous-parens) Unnecessary parens after keyword    
     enable=$enable,W0404          # reimported module    
-    enable=$enable,C0411          # (wrong-import-order), ] standard import "import x" comes before "import y"
+    enable=$enable,C0411          # (wrong-import-order), standard import "import x" comes before "import y"
+    enable=$enable,W0108          # (unnecessary-lambda), Lambda may not be necessary
 
     # enable=$enable,W0403        # relative import
     # enable=$enable,W0622        # (redefined-builtin) Redefining built-in