[elbe-devel] [PATCH 09/40] pylint: fix Attribute <x> defined outside __init__

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


avoid the pylint warning by preinitialize class members
with 'None' in __init__

Signed-off-by: Manuel Traut <manut at linutronix.de>
---
 elbepack/asyncworker.py    | 8 +++++---
 elbepack/debianize/base.py | 7 +++++++
 elbepack/updated.py        | 1 +
 3 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/elbepack/asyncworker.py b/elbepack/asyncworker.py
index 7f6173ba..313d9234 100644
--- a/elbepack/asyncworker.py
+++ b/elbepack/asyncworker.py
@@ -23,6 +23,7 @@ from elbepack.elbeproject import AptCacheCommitError, AptCacheUpdateError
 class AsyncWorkerJob(object):
     def __init__(self, project):
         self.project = project
+        self.old_status = None
 
     def enqueue(self, queue, db):
         queue.put(self)
@@ -381,6 +382,7 @@ class GenUpdateJob(AsyncWorkerJob):
         self.name = project.xml.text("/project/name")
         self.base_version = base_version
         self.current_version = project.xml.text("/project/version")
+        self.base_version_xml = None
         AsyncWorkerJob.__init__(self, project)
 
     def enqueue(self, queue, db):
@@ -427,12 +429,12 @@ class SaveVersionJob(AsyncWorkerJob):
     def __init__(self, project, description):
         AsyncWorkerJob.__init__(self, project)
         self.description = description
+        self.name = self.project.xml.text("project/name")
+        self.version = self.project.xml.text("project/version")
 
     def enqueue(self, queue, db):
         self.old_status = db.set_busy(self.project.builddir,
                                       ["build_done", "has_changes"])
-        self.name = self.project.xml.text("project/name")
-        self.version = self.project.xml.text("project/version")
 
         # Create the database entry now. This has the advantage that the
         # user will see an error message immediately, if he tries to use
@@ -474,9 +476,9 @@ class CheckoutVersionJob(AsyncWorkerJob):
     def __init__(self, project, version):
         AsyncWorkerJob.__init__(self, project)
         self.version = version
+        self.name = project.xml.text("project/name")
 
     def enqueue(self, queue, db):
-        self.name = self.project.xml.text("project/name")
         old_status = db.set_busy(self.project.builddir,
                                  ["build_done", "has_changes", "build_failed"])
 
diff --git a/elbepack/debianize/base.py b/elbepack/debianize/base.py
index b9aaf74c..c17a0da9 100644
--- a/elbepack/debianize/base.py
+++ b/elbepack/debianize/base.py
@@ -43,6 +43,13 @@ class DebianizeBase (FormMultiPage):
     def __init__(self):
         self.deb = {}
         self.tmpl_dir = None
+        self.p_name = None
+        self.p_version = None
+        self.p_arch = None
+        self.m_name = None
+        self.m_mail = None
+        self.release = None
+        self.source_format = None
 
         self.archs = ["arm64", "armhf", "armel", "amd64", "i386", "powerpc"]
         self.formats = ["native", "git", "quilt"]
diff --git a/elbepack/updated.py b/elbepack/updated.py
index f0254d75..af4207f0 100644
--- a/elbepack/updated.py
+++ b/elbepack/updated.py
@@ -156,6 +156,7 @@ class rw_access_file(object):
     def __init__(self, filename, status):
         self.filename = filename
         self.rw = rw_access(filename, status)
+        self.f = None
 
     def __enter__(self):
         self.rw.__enter__()
-- 
2.19.0.rc2




More information about the elbe-devel mailing list