[libvirt] [PATCH 6/6] hyperv: use "is None" not "== None" for PEP-8 compliance

Daniel P. Berrangé posted 6 patches 7 years ago
[libvirt] [PATCH 6/6] hyperv: use "is None" not "== None" for PEP-8 compliance
Posted by Daniel P. Berrangé 7 years ago
PEP 8 says:

    "Comparisons to singletons like None should always be done
     with 'is' or 'is not', never the equality operators."

There are potentially semantics differences, though in the case of this
libvirt code its merely a style change:

  http://jaredgrubb.blogspot.com/2009/04/python-is-none-vs-none.html

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 src/hyperv/hyperv_wmi_generator.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/hyperv/hyperv_wmi_generator.py b/src/hyperv/hyperv_wmi_generator.py
index fc1370955f..a9ece0ff00 100755
--- a/src/hyperv/hyperv_wmi_generator.py
+++ b/src/hyperv/hyperv_wmi_generator.py
@@ -65,7 +65,7 @@ class WmiClass:
         # because we'll generate "common" member and will be the "base" name
         if len(self.versions) > 1:
             first = self.versions[0]
-            if first.version == None:
+            if first.version is None:
                 first.version = "v1"
             first.name = "%s_%s" % (first.name, first.version)
 
-- 
2.20.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 6/6] hyperv: use "is None" not "== None" for PEP-8 compliance
Posted by John Ferlan 7 years ago

On 1/30/19 12:40 PM, Daniel P. Berrangé wrote:
> PEP 8 says:
> 
>     "Comparisons to singletons like None should always be done
>      with 'is' or 'is not', never the equality operators."
> 
> There are potentially semantics differences, though in the case of this
> libvirt code its merely a style change:
> 
>   http://jaredgrubb.blogspot.com/2009/04/python-is-none-vs-none.html
> 
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
>  src/hyperv/hyperv_wmi_generator.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 

Reviewed-by: John Ferlan <jferlan@redhat.com>

John

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list