From 7ebd5a3fce883696e19a146d4cc90f5631b2f823 Mon Sep 17 00:00:00 2001 From: Sourcery AI <> Date: Wed, 5 Apr 2023 16:56:49 +0000 Subject: [PATCH] 'Refactored by Sourcery' --- mss/linux.py | 6 ++---- mss/windows.py | 5 ++--- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/mss/linux.py b/mss/linux.py index 916efa8d..ba60bce7 100644 --- a/mss/linux.py +++ b/mss/linux.py @@ -333,8 +333,7 @@ def __init__( self.xrandr = ctypes.cdll.LoadLibrary(xrandr) if self.with_cursor: - xfixes = ctypes.util.find_library("Xfixes") - if xfixes: + if xfixes := ctypes.util.find_library("Xfixes"): self.xfixes = ctypes.cdll.LoadLibrary(xfixes) else: self.with_cursor = False @@ -379,8 +378,7 @@ def _get_display(self, disp: Optional[bytes] = None) -> int: *display* value first. """ current_thread = threading.current_thread() - current_display = MSS._display_dict.get(current_thread) - if current_display: + if current_display := MSS._display_dict.get(current_thread): display = current_display else: display = self.xlib.XOpenDisplay(disp) diff --git a/mss/windows.py b/mss/windows.py index 04f26e67..dbc2f65f 100644 --- a/mss/windows.py +++ b/mss/windows.py @@ -170,10 +170,9 @@ def _get_srcdc(self) -> int: Since the current thread and main thread are always alive, reuse their *srcdc* value first. """ cur_thread, main_thread = threading.current_thread(), threading.main_thread() - current_srcdc = MSS._srcdc_dict.get(cur_thread) or MSS._srcdc_dict.get( + if current_srcdc := MSS._srcdc_dict.get(cur_thread) or MSS._srcdc_dict.get( main_thread - ) - if current_srcdc: + ): srcdc = current_srcdc else: srcdc = self.user32.GetWindowDC(0)