Message ID | 20220219201957.8329-2-zygmunt.krynicki@huawei.com |
---|---|
State | New |
Headers | show |
Series | [1/3] simplediff: Remove redundant parentheses | expand |
diff --git a/lib/simplediff/__init__.py b/lib/simplediff/__init__.py index 11eb7e70..64ec64b4 100644 --- a/lib/simplediff/__init__.py +++ b/lib/simplediff/__init__.py @@ -100,7 +100,7 @@ def diff(old, new): if sub_length == 0: # If no common substring is found, we return an insert and delete... - return (old and [('-', old)] or []) + (new and [('+', new)] or []) + return ([('-', old)] if old else []) + ([('+', new)] if new else []) else: # ...otherwise, the common substring is unchanged and we recursively # diff the text before and after that substring
The diff code used "a and b or c" as an old-style Python implementation of the ternary operator. The more correct way to do this is to use "b if a else c", as it has cleaner type signature. Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@huawei.com> --- lib/simplediff/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)