From a8b3feac86c0800968a52db1ff48477076f106c4 Mon Sep 17 00:00:00 2001 From: TheNooB <73348767+TheNooB2706@users.noreply.github.com> Date: Fri, 11 Aug 2023 21:01:05 +0800 Subject: [PATCH] Apply suggestions from code review Simplify conditional expressions Co-authored-by: Andrew Murray <3112309+radarhere@users.noreply.github.com> --- src/PIL/ImageGrab.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/PIL/ImageGrab.py b/src/PIL/ImageGrab.py index 44bc6d38f..c510c835f 100644 --- a/src/PIL/ImageGrab.py +++ b/src/PIL/ImageGrab.py @@ -164,9 +164,7 @@ def grabclipboard(): else: # Session type check failed sessiontype = None - if shutil.which("wl-paste") and ( - (sessiontype == "wayland") or (sessiontype is None) - ): + if shutil.which("wl-paste") and sessiontype in ["wayland", None]: output = subprocess.check_output(["wl-paste", "-l"]).decode() mimetypes = output.splitlines() if "image/png" in mimetypes: @@ -179,9 +177,7 @@ def grabclipboard(): args = ["wl-paste"] if mimetype: args.extend(["-t", mimetype]) - elif shutil.which("xclip") and ( - (sessiontype == "x11") or (sessiontype is None) - ): + elif shutil.which("xclip") and sessiontype in ["x11", None]: args = ["xclip", "-selection", "clipboard", "-t", "image/png", "-o"] else: msg = "wl-paste or xclip is required for ImageGrab.grabclipboard() on Linux"