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

Manuel Traut manut at linutronix.de
Fri Sep 21 11:00:48 CEST 2018


On Thu, Sep 20, 2018 at 11:21:58AM +0200, Torben Hohn wrote:
> On Fri, Sep 14, 2018 at 01:56:21PM +0200, Manuel Traut wrote:
> > 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(-)
> > 
> > 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
> 
> iirc there was a subtle problem with this.
> but maybe i had tried to set the fields to default strings,
> and this failed.
> 

you're right:

$ cd linux
$ elbe debianize
[...]
File "/home/local/projects/elbe/elbe/elbepack/debianize/kernel.py", line 67, in debianize
    self.deb['loadaddr'] = self.loadaddr.get_value()
AttributeError: 'NoneType' object has no attribute 'get_value'

  Manuel

> >  
> >          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
> > 
> 
> -- 
> Torben Hohn
> Linutronix GmbH | Bahnhofstrasse 3 | D-88690 Uhldingen-Mühlhofen
> Phone: +49 7556 25 999 18; Fax.: +49 7556 25 999 99
> 
> Hinweise zum Datenschutz finden Sie hier (Informations on data privacy 
> can be found here): https://linutronix.de/kontakt/Datenschutz.php
> 
> Linutronix GmbH | Firmensitz (Registered Office): Uhldingen-Mühlhofen | 
> Registergericht (Registration Court): Amtsgericht Freiburg i.Br., HRB700 
> 806 | Geschäftsführer (Managing Directors): Heinz Egger, Thomas Gleixner





More information about the elbe-devel mailing list