Skip to contentSkip to conversation

KVM-test: kvm.py: Code style fix

PATCH In review Marc Enthus 3 participants 3 messages Jun 8, 2010 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 KVM-test: kvm.py: Code style fix

From: Marc Enthus <[email protected]>

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:

---
 client/tests/kvm/kvm_vm.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
client/tests/kvm/kvm_vm.py +1 -1
index f3ce4d6..0080b15 100755
@@ -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
#1 lore raw
Quoted 22 lines · Marc Enthus

From: Marc Enthus <[email protected]>

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:

---
 client/tests/kvm/kvm_vm.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
client/tests/kvm/kvm_vm.py +0 -0
index f3ce4d6..0080b15 100755

client/tests/kvm/kvm_vm.py class VM: · line 522

Quoted 8 lines
client/tests/kvm/kvm_vm.py +1 -1
@@ -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.

#2 lore raw
Quoted 28 lines · Michael Goldish
Quoted 27 lines · Marc Enthus

From: Marc Enthus <[email protected]>

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:

---
 client/tests/kvm/kvm_vm.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
client/tests/kvm/kvm_vm.py +1 -1
index f3ce4d6..0080b15 100755
@@ -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)
 
Quoted 8 lines

client/tests/kvm/kvm_vm.py class VM: · line 522

Quoted 3 lines
client/tests/kvm/kvm_vm.py +0 -0
             # 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!