[elbe-devel] [PATCH 37/40] pylint: directories - annotate usage of global

Manuel Traut manut at linutronix.de
Fri Sep 14 13:56:49 CEST 2018


global is really what should be used there. Because
the values should be accessible by other modules.

It would be feasable to rewrite the code to be a class
and use class variables for this. But i don't really
see a reason for this.

Signed-off-by: Manuel Traut <manut at linutronix.de>
---
 elbepack/directories.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/elbepack/directories.py b/elbepack/directories.py
index d81cb72f..3909dbaa 100644
--- a/elbepack/directories.py
+++ b/elbepack/directories.py
@@ -17,9 +17,11 @@ examples_dir = None
 
 
 def init_directories(elbe_relpath):
-    global elbe_exe
-    global elbe_dir
-    global examples_dir
+    # set global variables that are used in other modules via imports
+    # this is the very first function that is called by 'elbe'
+    global elbe_exe      #pylint: disable=global-statement
+    global elbe_dir      #pylint: disable=global-statement
+    global examples_dir  #pylint: disable=global-statement
 
     elbe_exe = os.path.abspath(elbe_relpath)
     elbe_dir = os.path.dirname(elbe_exe)
-- 
2.19.0.rc2




More information about the elbe-devel mailing list