public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM-test: kvm.py: Code style fix
@ 2010-06-08  8:02 Marc Enthus
  2010-06-08 17:50 ` Michael Goldish
  0 siblings, 1 reply; 3+ messages in thread
From: Marc Enthus @ 2010-06-08  8:02 UTC (permalink / raw)
  To: lmr, mgoldish, autotest; +Cc: kvm

From: Marc Enthus <cxzdes@gmail.com>

According to autotest coding style
and http://www.python.org/dev/peps/pep-0008/

use
	if pa_type is not None:
instead of
	if pa_type:

Signed-off-by: Marc Enthus <cxzdes@gmail.com>
---
 client/tests/kvm/kvm_vm.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py
index f3ce4d6..0080b15 100755
--- a/client/tests/kvm/kvm_vm.py
+++ b/client/tests/kvm/kvm_vm.py
@@ -516,7 +516,7 @@ class VM:
                                   pa_type)
                     return False
 
-            elif pa_type and pa_type != "no":
+            elif pa_type is not None and pa_type != "no":
                 logging.warn("Unsupported pci_assignable type: %s", pa_type)
 
             # Make qemu command



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] KVM-test: kvm.py: Code style fix
  2010-06-08  8:02 [PATCH] KVM-test: kvm.py: Code style fix Marc Enthus
@ 2010-06-08 17:50 ` Michael Goldish
  2010-06-08 18:22   ` Lucas Meneghel Rodrigues
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Goldish @ 2010-06-08 17:50 UTC (permalink / raw)
  To: Marc Enthus; +Cc: autotest, kvm

On 06/08/2010 11:02 AM, Marc Enthus wrote:
> From: Marc Enthus <cxzdes@gmail.com>
> 
> According to autotest coding style
> and http://www.python.org/dev/peps/pep-0008/
> 
> use
> 	if pa_type is not None:
> instead of
> 	if pa_type:
> 
> Signed-off-by: Marc Enthus <cxzdes@gmail.com>
> ---
>  client/tests/kvm/kvm_vm.py |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py
> index f3ce4d6..0080b15 100755
> --- a/client/tests/kvm/kvm_vm.py
> +++ b/client/tests/kvm/kvm_vm.py
> @@ -516,7 +516,7 @@ class VM:
>                                    pa_type)
>                      return False
>  
> -            elif pa_type and pa_type != "no":
> +            elif pa_type is not None and pa_type != "no":
>                  logging.warn("Unsupported pci_assignable type: %s", pa_type)
>  
>              # Make qemu command
> 
> 

The condition 'if pa_type' is meant to exclude both None and "".  Both
are possible and both indicate that the user isn't interested in pa_type
at all.  In that case 'if pa_type' conforms to PEP 8 AFAIK.  I'm not
sure about the autotest coding style though.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] KVM-test: kvm.py: Code style fix
  2010-06-08 17:50 ` Michael Goldish
@ 2010-06-08 18:22   ` Lucas Meneghel Rodrigues
  0 siblings, 0 replies; 3+ messages in thread
From: Lucas Meneghel Rodrigues @ 2010-06-08 18:22 UTC (permalink / raw)
  To: Michael Goldish; +Cc: autotest, Marc Enthus, kvm

On Tue, 2010-06-08 at 20:50 +0300, Michael Goldish wrote:
> On 06/08/2010 11:02 AM, Marc Enthus wrote:
> > From: Marc Enthus <cxzdes@gmail.com>
> > 
> > According to autotest coding style
> > and http://www.python.org/dev/peps/pep-0008/
> > 
> > use
> > 	if pa_type is not None:
> > instead of
> > 	if pa_type:
> > 
> > Signed-off-by: Marc Enthus <cxzdes@gmail.com>
> > ---
> >  client/tests/kvm/kvm_vm.py |    2 +-
> >  1 files changed, 1 insertions(+), 1 deletions(-)
> > 
> > diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py
> > index f3ce4d6..0080b15 100755
> > --- a/client/tests/kvm/kvm_vm.py
> > +++ b/client/tests/kvm/kvm_vm.py
> > @@ -516,7 +516,7 @@ class VM:
> >                                    pa_type)
> >                      return False
> >  
> > -            elif pa_type and pa_type != "no":
> > +            elif pa_type is not None and pa_type != "no":
> >                  logging.warn("Unsupported pci_assignable type: %s", pa_type)
> >  
> >              # Make qemu command
> > 
> > 
> 
> The condition 'if pa_type' is meant to exclude both None and "".  Both
> are possible and both indicate that the user isn't interested in pa_type
> at all.  In that case 'if pa_type' conforms to PEP 8 AFAIK.  I'm not
> sure about the autotest coding style though.

Yes, turns out I have overlooked the possibility of pa_type being "".
I'll revert this fix, thanks for pointing this out!

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-06-08 18:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-08  8:02 [PATCH] KVM-test: kvm.py: Code style fix Marc Enthus
2010-06-08 17:50 ` Michael Goldish
2010-06-08 18:22   ` Lucas Meneghel Rodrigues

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox