fix pylint warning '(global-variable-not-assigned) Using global for 'X' but no assignment is done'
authorAndrey Skvortsov <andrej.skvortzov@gmail.com>
Mon, 02 Oct 2017 13:19:06 +0300
changeset 1841 9fd29e8b1393
parent 1840 cf5ef4c0deff
child 1842 05c1f7aa8991
fix pylint warning '(global-variable-not-assigned) Using global for 'X' but no assignment is done'
Beremiz_service.py
connectors/WAMP/__init__.py
controls/DebugVariablePanel/DebugVariableViewer.py
editors/Viewer.py
runtime/WampClient.py
svgui/pyjs/lib/pyjslib.py
svgui/pyjs/lib/sys.py
tests/tools/check_source.sh
--- a/Beremiz_service.py	Mon Oct 02 12:43:01 2017 +0300
+++ b/Beremiz_service.py	Mon Oct 02 13:19:06 2017 +0300
@@ -510,7 +510,6 @@
         wx_eval_lock.release()
 
     def evaluator(tocall, *args, **kwargs):
-        global main_thread
         if main_thread == currentThread():
             # avoid dead lock if called from the wx mainloop
             return default_evaluator(tocall, *args, **kwargs)
--- a/connectors/WAMP/__init__.py	Mon Oct 02 12:43:01 2017 +0300
+++ b/connectors/WAMP/__init__.py	Mon Oct 02 13:19:06 2017 +0300
@@ -44,13 +44,13 @@
 
 class WampSession(wamp.ApplicationSession):
     def onJoin(self, details):
-        global _WampSession, _WampSessionEvent
+        global _WampSession
         _WampSession = self
         _WampSessionEvent.set()
         print('WAMP session joined for :', self.config.extra["ID"])
 
     def onLeave(self, details):
-        global _WampSession, _WampSessionEvent
+        global _WampSession
         _WampSessionEvent.clear()
         _WampSession = None
         print('WAMP session left')
@@ -113,7 +113,6 @@
         wampfuncname = '.'.join((ID, funcname))
 
         def catcher_func(*args, **kwargs):
-            global _WampSession
             if _WampSession is not None:
                 try:
                     return threads.blockingCallFromThread(
@@ -132,7 +131,7 @@
 
     class WampPLCObjectProxy(object):
         def __init__(self):
-            global _WampSessionEvent, _WampConnection
+            global _WampConnection
             if not reactor.running:
                 Thread(target=ThreadProc).start()
             else:
@@ -143,7 +142,6 @@
                 raise Exception(_("WAMP connection timeout"))
 
         def __del__(self):
-            global _WampConnection
             _WampConnection.disconnect()
             #
             # reactor.stop()
--- a/controls/DebugVariablePanel/DebugVariableViewer.py	Mon Oct 02 12:43:01 2017 +0300
+++ b/controls/DebugVariablePanel/DebugVariableViewer.py	Mon Oct 02 13:19:06 2017 +0300
@@ -83,7 +83,6 @@
         """
         Init global pens and brushes
         """
-        global HIGHLIGHT
         if not HIGHLIGHT:
             HIGHLIGHT['DROP_PEN'] = wx.Pen(wx.Colour(0, 128, 255))
             HIGHLIGHT['DROP_BRUSH'] = wx.Brush(wx.Colour(0, 128, 255, 128))
--- a/editors/Viewer.py	Mon Oct 02 12:43:01 2017 +0300
+++ b/editors/Viewer.py	Mon Oct 02 13:19:06 2017 +0300
@@ -810,7 +810,6 @@
 
     def SetCurrentCursor(self, cursor):
         if self.Mode != MODE_MOTION:
-            global CURSORS
             if self.CurrentCursor != cursor:
                 self.CurrentCursor = cursor
                 self.Editor.SetCursor(CURSORS[cursor])
--- a/runtime/WampClient.py	Mon Oct 02 12:43:01 2017 +0300
+++ b/runtime/WampClient.py	Mon Oct 02 13:19:06 2017 +0300
@@ -57,7 +57,6 @@
 
 def GetCallee(name):
     """ Get Callee or Subscriber corresponding to '.' spearated object path """
-    global _PySrv
     names = name.split('.')
     obj = _PySrv.plcobj
     while names:
@@ -134,7 +133,6 @@
 
 
 def GetSession():
-    global _WampSession
     return _WampSession
 
 
--- a/svgui/pyjs/lib/pyjslib.py	Mon Oct 02 12:43:01 2017 +0300
+++ b/svgui/pyjs/lib/pyjslib.py	Mon Oct 02 13:19:06 2017 +0300
@@ -598,7 +598,6 @@
 
     def sort(self, compareFunc=None, keyFunc=None, reverse=False):
         if not compareFunc:
-            global cmp
             compareFunc = cmp
         if keyFunc and reverse:
             def thisSort1(a, b):
@@ -749,7 +748,6 @@
 
     def sort(self, compareFunc=None, keyFunc=None, reverse=False):
         if not compareFunc:
-            global cmp
             compareFunc = cmp
         if keyFunc and reverse:
             def thisSort1(a, b):
--- a/svgui/pyjs/lib/sys.py	Mon Oct 02 12:43:01 2017 +0300
+++ b/svgui/pyjs/lib/sys.py	Mon Oct 02 13:19:06 2017 +0300
@@ -23,12 +23,10 @@
 
 
 def getloadpath():
-    global loadpath
     return loadpath
 
 
 def addoverride(module_name, path):
-    global overrides
     overrides[module_name] = path
 
 
--- a/tests/tools/check_source.sh	Mon Oct 02 12:43:01 2017 +0300
+++ b/tests/tools/check_source.sh	Mon Oct 02 13:19:06 2017 +0300
@@ -214,6 +214,7 @@
     enable=$enable,W0311          # (bad-indentation) Bad indentation. Found 16 spaces, expected 12
     enable=$enable,W0101          # (unreachable) Unreachable code
     enable=$enable,E0102          # (function-redefined) method already defined
+    enable=$enable,W0602          # (global-variable-not-assigned) Using global for 'X' but no assignment is done
 
     # enable=$enable,W0403        # relative import
     # enable=$enable,W0622        # (redefined-builtin) Redefining built-in