[blivet:master 2/3] Put size values in Size universe eagerly.

Anne Mulhern amulhern at redhat.com
Tue Nov 4 15:20:24 UTC 2014





----- Original Message -----
> From: "David Lehman" <dlehman at redhat.com>
> To: anaconda-patches at lists.fedorahosted.org
> Sent: Friday, October 31, 2014 3:57:40 PM
> Subject: Re: [blivet:master 2/3] Put size values in Size universe eagerly.
> 
> On 10/31/2014 10:31 AM, mulhern wrote:
> > Make everything that should be a Size a Size as soon as it is created,
> > for clarity, consistency, correctness.
> >
> > * Clarity --- it's a way for the programmer to state, yes, I believe this
> > is
> > a Size and I'm pretty confident about its units.
> > * Consistency --- a lot of methods say they return a Size, but many return
> > a
> > Size or an int, depending on the path taken through the method. Better to
> > make these methods actually return a Size always.
> > * Correctness --- type correctness and logical correctness. The more we
> > ensure that we have the right type, the less likely we are to get an
> > AttributeError invoking convertTo() or humanReadable() on an int or a
> > Decimal. When we use Size we are required to specify the units, at least
> > implicitly, so we can better avoid intepreting a bare number as, for
> > example,
> > 1/1024th of its intended value.
> >
> > Other changes in this patch:
> > * For the first argument of sum(), use a generator, not a list.
> > * Use // for division when a whole number is required (instead of casting
> > to
> > an int after the division).
> 
> This is changing at least one documented int to a Decimal -- probably
> more. Have you verified that pyparted is content with Decimal for
> sectors and lengths? Any autopart installation using anaconda in a vm
> should be sufficient to establish this.
> 

Thanks for pointing this out. I do not see any import of decimal anywhere in
the pyparted codebase. It seems like the wise thing to do is to avoid
passing a Decimal as an argument to a pyparted method (and to avoid passing a
Size even more).

- mulhern




More information about the anaconda-patches mailing list