[elbe-devel] [PATCH 6/7] pep8: fix E741 ambiguous variable name 'l'

Torben Hohn torben.hohn at linutronix.de
Fri Jan 5 11:39:55 CET 2018


On Thu, Dec 21, 2017 at 11:57:34AM +0100, Manuel Traut wrote:
> Hi,
> 
> i just noticed that this change triggers an error:
> 
>   Traceback (most recent call last):
>     File "/var/cache/elbe/devel/elbepack/asyncworker.py", line 102, in execute
>       skip_pbuild=self.skip_pbuilder)
>     File "/var/cache/elbe/devel/elbepack/elbeproject.py", line 240, in build
>       self.xml.validate_apt_sources(m, self.arch)
>     File "/var/cache/elbe/devel/elbepack/elbexml.py", line 184, in validate_apt_sources
>       srcline = re.sub(r'\[.*\] ', '', l)
>   NameError: global name 'l' is not defined
> 
> It will be fixed in v2.

Dont name the iterator variable source_line, thats too long.
from: http://pycodestyle.pycqa.org/en/latest/intro.html

E741 	do not use variables named ‘l’, ‘O’, or ‘I’

i actually unhappy with not naming the variable l.

I propose i or ll or line, if you want it long.

But i would also be happy, if we ignored E741. Because
a font unable to distinguish I and l is not funny :)



> 
>   Manuel
> 
> On Wed, Dec 20, 2017 at 10:11:46PM +0100, Manuel Traut wrote:
> > this updates pycodestyle statistics to:
> > 
> > 99      E501 line too long (82 > 79 characters)
> > 
> > Signed-off-by: Manuel Traut <manut at linutronix.de>
> > ---
> >  elbepack/elbexml.py        | 12 ++++++------
> >  elbepack/licencexml.py     |  4 ++--
> >  elbepack/projectmanager.py | 16 ++++++++--------
> >  elbepack/rfs.py            |  6 +++---
> >  4 files changed, 19 insertions(+), 19 deletions(-)
> > 
> > diff --git a/elbepack/elbexml.py b/elbepack/elbexml.py
> > index ab1a2c92..d2c2a6a6 100644
> > --- a/elbepack/elbexml.py
> > +++ b/elbepack/elbexml.py
> > @@ -180,16 +180,16 @@ class ElbeXML(object):
> >          sources_lines = slist.split('\n')
> >  
> >          repos = []
> > -        for l in sources_lines:
> > -            l = re.sub(r'\[.*\] ', '', l)
> > -            if l.startswith("deb copy:"):
> > +        for source_line in sources_lines:
> > +            source_line = re.sub(r'\[.*\] ', '', l)
> > +            if source_line.startswith("deb copy:"):
> >                  # This is a cdrom, we dont verify it
> >                  pass
> > -            elif l.startswith("deb-src copy:"):
> > +            elif source_line.startswith("deb-src copy:"):
> >                  # This is a cdrom, we dont verify it
> >                  pass
> > -            elif l.startswith("deb ") or l.startswith("deb-src "):
> > -                lsplit = l.split(" ")
> > +            elif source_line.startswith("deb ") or source_line.startswith("deb-src "):
> > +                lsplit = source_line.split(" ")
> >                  url = lsplit[1]
> >                  suite = lsplit[2]
> >                  section = lsplit[3]
> > diff --git a/elbepack/licencexml.py b/elbepack/licencexml.py
> > index f5db9cc8..71278c37 100644
> > --- a/elbepack/licencexml.py
> > +++ b/elbepack/licencexml.py
> > @@ -101,8 +101,8 @@ class copyright_xml (object):
> >              xmlpkg.append('heuristics')
> >              xmllic = xmlpkg.append('debian_licenses')
> >              for i in lics:
> > -                l = xmllic.append('license')
> > -                l.et.text = i
> > +                ltag = xmllic.append('license')
> > +                ltag.et.text = i
> >  
> >              return
> >  
> > diff --git a/elbepack/projectmanager.py b/elbepack/projectmanager.py
> > index c775ed1a..f039da9c 100644
> > --- a/elbepack/projectmanager.py
> > +++ b/elbepack/projectmanager.py
> > @@ -527,18 +527,18 @@ class ProjectManager(object):
> >              if part is None:
> >                  return self.db.is_busy(ep.builddir), ""
> >  
> > -            l = None
> > +            logline = None
> >              with open(os.path.join(ep.builddir, 'log.txt'), 'r', 0) as lf:
> > -                for l in lf:
> > +                for logline in lf:
> >                      if count == part:
> > -                        l = str(part + 1) + '###' + str(l)
> > -                        return self.db.is_busy(ep.builddir), str(l)
> > +                        logline = str(part + 1) + '###' + str(logline)
> > +                        return self.db.is_busy(ep.builddir), str(logline)
> >                      count = count + 1
> >              # don't crash if logfile doesn't exist
> > -            if not l:
> > -                l = None
> > -            l = str(part) + '###' + str(l)
> > -            return self.db.is_busy(ep.builddir), l
> > +            if not logline:
> > +                logline = None
> > +            logline = str(part) + '###' + str(logline)
> > +            return self.db.is_busy(ep.builddir), logline
> >  
> >      def _get_current_project(self, userid, allow_busy=True):
> >          # Must be called with self.lock held
> > diff --git a/elbepack/rfs.py b/elbepack/rfs.py
> > index 6272c61e..1afe96a9 100644
> > --- a/elbepack/rfs.py
> > +++ b/elbepack/rfs.py
> > @@ -190,10 +190,10 @@ class BuildEnv ():
> >          if self.xml.has('project/mirror/url-list'):
> >              for url in self.xml.node('project/mirror/url-list'):
> >                  if url.has('key'):
> > -                    l = url.text('key').strip()    # URL to key
> > -                    name = l.split('/')[-1]        # Filename of key
> > +                    keyurl = url.text('key').strip()    # URL to key
> > +                    name = keyurl.split('/')[-1]        # Filename of key
> >  
> > -                    myKey = urllib2.urlopen(l).read()
> > +                    myKey = urllib2.urlopen(keyurl).read()
> >                      self.log.do(
> >                          'echo "%s" > %s' %
> >                          (myKey, self.rfs.fname("tmp/key.pub")))
> > -- 
> > 2.15.1
> > 
> 
> _______________________________________________
> elbe-devel mailing list
> elbe-devel at linutronix.de
> https://lists.linutronix.de/mailman/listinfo/elbe-devel

-- 
Mit freundlichen Grüßen
Torben Hohn

Linutronix GmbH

Standort: Bremen

Phone: +49 7556 25 999 18; Fax.: +49 7556 25 999 99

Firmensitz / Registered Office: D-88690 Uhldingen, Bahnhofstr. 3
Registergericht / Local District Court: Amtsgericht Freiburg i. Br.; HRB
Nr. / Trade register no.: 700 806

Geschäftsführer / Managing Directors: Heinz Egger, Thomas Gleixner

Eine Bitte von uns: Sollten Sie diese E-Mail irrtümlich erhalten haben,
benachrichtigen Sie uns in diesem Falle bitte sobald wie es Ihnen
möglich ist, durch Antwort-Mail. Vielen Dank!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <http://lists.linutronix.de/pipermail/elbe-devel/attachments/20180105/ede3a0e6/attachment.sig>


More information about the elbe-devel mailing list