[blivet:master 3/3] Suppress unused variable warnings for index in range

Anne Mulhern amulhern at redhat.com
Tue Mar 25 11:41:41 UTC 2014





----- Original Message -----
> From: "Vratislav Podzimek" <vpodzime at redhat.com>
> To: "anaconda patch review" <anaconda-patches at lists.fedorahosted.org>
> Sent: Tuesday, March 25, 2014 6:58:27 AM
> Subject: Re: [blivet:master 3/3] Suppress unused variable warnings for index	in range
> 
> On Mon, 2014-03-24 at 13:35 -0400, mulhern wrote:
> > Signed-off-by: mulhern <amulhern at redhat.com>
> > ---
> >  blivet/devices.py                   |  3 ++-
> >  tests/formats_test/labeling_test.py | 10 +++++-----
> >  2 files changed, 7 insertions(+), 6 deletions(-)
> > 
> > diff --git a/blivet/devices.py b/blivet/devices.py
> > index acd6780..50c8dd1 100644
> > --- a/blivet/devices.py
> > +++ b/blivet/devices.py
> > @@ -3900,7 +3900,8 @@ class FileDevice(StorageDevice):
> >          MiB = Size(spec="1 MiB")
> >          count = int(self.size.convertTo(spec="MiB"))
> >          rem = self.size % MiB
> > -        for n in range(count):
> > +
> > +        for _n in range(count):
> >              os.write(fd, zero * MiB)
> This should use xrange(), but that would complicate transition to
> Python3, so hard to say if we should change it now.
> 

Leaving...

> >  
> >          if rem:
> > diff --git a/tests/formats_test/labeling_test.py
> > b/tests/formats_test/labeling_test.py
> > index f4b9aa1..51c077a 100755
> > --- a/tests/formats_test/labeling_test.py
> > +++ b/tests/formats_test/labeling_test.py
> > @@ -37,14 +37,14 @@ class InitializationTestCase(unittest.TestCase):
> >          self.assertTrue(fs.XFS.labelFormatOK("root_filesys"))
> >  
> >          #HFS has a maximum length of 27, minimum length of 1, and does not
> >          allow colons
> > -        self.assertFalse(fs.HFS.labelFormatOK("".join(["n" for x in
> > range(28)])))
> > +        self.assertFalse(fs.HFS.labelFormatOK("".join(["n" for _x in
> > range(28)])))
> >          self.assertFalse(fs.HFS.labelFormatOK("root:file"))
> >          self.assertFalse(fs.HFS.labelFormatOK(""))
> > -        self.assertTrue(fs.HFS.labelFormatOK("".join(["n" for x in
> > range(27)])))
> > +        self.assertTrue(fs.HFS.labelFormatOK("".join(["n" for _x in
> > range(27)])))
> >  
> >          # NTFS has a maximum length of 128
> > -        self.assertFalse(fs.NTFS.labelFormatOK("".join(["n" for x in
> > range(129)])))
> > -        self.assertTrue(fs.NTFS.labelFormatOK("".join(["n" for x in
> > range(128)])))
> > +        self.assertFalse(fs.NTFS.labelFormatOK("".join(["n" for _x in
> > range(129)])))
> > +        self.assertTrue(fs.NTFS.labelFormatOK("".join(["n" for _x in
> > range(128)])))
> >  
> >          # all devices are permitted to be passed a label argument of None
> >          # some will ignore it completely
> > @@ -118,7 +118,7 @@ class
> > ReiserFSTestCase(fslabeling.LabelingWithRelabeling):
> >  class HFSTestCase(fslabeling.LabelingAsRoot):
> >      def setUp(self):
> >          self._fs_class = fs.HFS
> > -        self._invalid_label = "".join(["n" for x in range(28)])
> > +        self._invalid_label = "".join(["n" for _x in range(28)])
> These should all be just "n" * 28 etc. instead of calling join on an
> empty string with range.
> 

Yup, thanks. Fixed in working copy.

> --
> Vratislav Podzimek
> 
> Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic
> 
> _______________________________________________
> anaconda-patches mailing list
> anaconda-patches at lists.fedorahosted.org
> https://lists.fedorahosted.org/mailman/listinfo/anaconda-patches
> 


More information about the anaconda-patches mailing list