fix pylint error '(unsubscriptable-object) Value 'X' is unsubscriptable'
authorAndrey Skvortsov <andrej.skvortzov@gmail.com>
Thu, 19 Oct 2017 13:33:01 +0300
changeset 1879 4d81c3bcac82
parent 1878 fb73a6b6622d
child 1880 e5ddbaf756cb
fix pylint error '(unsubscriptable-object) Value 'X' is unsubscriptable'
PLCControler.py
svgui/pyjs/lib/sys.py
tests/tools/check_source.sh
--- a/PLCControler.py	Thu Oct 19 11:03:03 2017 +0300
+++ b/PLCControler.py	Thu Oct 19 13:33:01 2017 +0300
@@ -1629,14 +1629,14 @@
 
     # Function that returns the block definition associated to the block type given
     def GetBlockType(self, typename, inputs=None, debug=False):
-        result_blocktype = None
+        result_blocktype = {}
         for _sectioname, blocktype in self.TotalTypesDict.get(typename, []):
             if inputs is not None and inputs != "undefined":
                 block_inputs = tuple([var_type for _name, var_type, _modifier in blocktype["inputs"]])
                 if reduce(lambda x, y: x and y, map(lambda x: x[0] == "ANY" or self.IsOfType(*x), zip(inputs, block_inputs)), True):
                     return blocktype
             else:
-                if result_blocktype is not None:
+                if result_blocktype:
                     if inputs == "undefined":
                         return None
                     else:
@@ -1644,7 +1644,7 @@
                         result_blocktype["outputs"] = [(o[0], "ANY", o[2]) for o in result_blocktype["outputs"]]
                         return result_blocktype
                 result_blocktype = blocktype.copy()
-        if result_blocktype is not None:
+        if result_blocktype:
             return result_blocktype
         project = self.GetProject(debug)
         if project is not None:
--- a/svgui/pyjs/lib/sys.py	Thu Oct 19 11:03:03 2017 +0300
+++ b/svgui/pyjs/lib/sys.py	Thu Oct 19 13:33:01 2017 +0300
@@ -2,7 +2,7 @@
 platform = ''  # to be updated by app, on compile
 
 # a dictionary of module override names (platform-specific)
-overrides = None  # to be updated by app, on compile
+overrides = {}  # to be updated by app, on compile
 
 # the remote path for loading modules
 loadpath = None
--- a/tests/tools/check_source.sh	Thu Oct 19 11:03:03 2017 +0300
+++ b/tests/tools/check_source.sh	Thu Oct 19 13:33:01 2017 +0300
@@ -206,6 +206,8 @@
     disable=$disable,I0011        # (locally-disabled) Locally disabling ungrouped-imports (C0412)
     disable=$disable,R0204        # (redefined-variable-type) Redefinition of current type from X to Y
     disable=$disable,R0201        # (no-self-use) Method could be a function
+    disable=$disable,W0221        # (arguments-differ) Arguments number differs from overridden 'X' method
+    disable=$disable,C0201        # (consider-iterating-dictionary) Consider iterating the dictionary directly instead of calling .keys()
 
     # It'd be nice to fix warnings below some day
     disable=$disable,C0111        # missing-docstring
@@ -226,6 +228,7 @@
     disable=$disable,R0101        # (too-many-nested-blocks) Too many nested blocks (7/5)
     disable=$disable,R0801        # (duplicate-code) Similar lines in N files
 
+
     enable=
     enable=$enable,E1601          # print statement used
     enable=$enable,C0325          # (superfluous-parens) Unnecessary parens after keyword    
@@ -268,6 +271,7 @@
     enable=$enable,W0623          # (redefine-in-handler) Redefining name 'X' from outer scope (line Y) in exception handler
     enable=$enable,W0106          # (expression-not-assigned) Expression "X" is assigned to nothing
     enable=$enable,C0330          # (bad-continuation) Wrong hanging indentation before block
+    enable=$enable,E1136          # (unsubscriptable-object) Value 'X' is unsubscriptable
     # enable=
 
     options=