Re: [libvirt PATCH] rpcgen: use proper operators when comparing types

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11/4/23 01:04, Laine Stump wrote:
> flake8 (run on all python scripts as a part of the syntax checks)
> version 6.1.0 (on macOS 14) issued many complaints like this on the
> new rpcgen python scripts:
> 
> [...]libvirt/scripts/rpcgen/rpcgen/lexer.py:57:17: E721 do not compare types, for exact checks use `is` / `is not`, for instance checks use `isinstance()`
> 
> This patch changes all [type] == [type] to use "is" instead of "==",
> and similarly to use "is not" instead of "!=".
> 
> (flake8 5.03, e.g. on Fedora 38, is just fine with using "==" and "!=",
> but python on both likes "is" and "is not")
> 
> Fixes: commit v9.9.0-24-g8ec79e5e14
> Fixes: commit v9.9.0-22-gca3f025011
> Fixes: commit v9.9.0-21-g031efb691f
> Fixes: commit v9.9.0-20-g8c8b97685b
> 
> Signed-off-by: Laine Stump <laine@xxxxxxxxxx>
> ---
>  scripts/rpcgen/rpcgen/ast.py       |  4 +-
>  scripts/rpcgen/rpcgen/generator.py | 26 ++++++------
>  scripts/rpcgen/rpcgen/lexer.py     |  2 +-
>  scripts/rpcgen/rpcgen/parser.py    | 68 +++++++++++++++---------------
>  4 files changed, 50 insertions(+), 50 deletions(-)
> 
> diff --git a/scripts/rpcgen/rpcgen/ast.py b/scripts/rpcgen/rpcgen/ast.py
> index 3e3e089713..52d9c3ac46 100644
> --- a/scripts/rpcgen/rpcgen/ast.py
> +++ b/scripts/rpcgen/rpcgen/ast.py
> @@ -185,9 +185,9 @@ class XDRTypeCustom(XDRType):
>          self.definition = definition
>  
>      def is_scalar(self):
> -        if type(self.definition) == XDRDefinitionEnum:
> +        if type(self.definition) is XDRDefinitionEnum:

D'oh! And I just started rewriting this into isinstace() and only after
that I noticed this patch. I guess we don't need to worry about subclases.

Michal
_______________________________________________
Devel mailing list -- devel@xxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux