From c55313a9638648e7e7c2d31931d058bed5baa7e5 Mon Sep 17 00:00:00 2001 From: Alex Huszagh Date: Sat, 7 Sep 2024 11:08:06 -0500 Subject: [PATCH] Fix our linters for non-Windows systems. --- example/advanced-dock.py | 2 +- example/breeze_theme.py | 13 ++++++++----- example/shared.py | 2 ++ 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/example/advanced-dock.py b/example/advanced-dock.py index 693f6cd..29b585b 100644 --- a/example/advanced-dock.py +++ b/example/advanced-dock.py @@ -29,7 +29,7 @@ Simple PyQt application using the advanced-docking-system. ''' -# pylint: disable=no-name-in-module +# pylint: disable=no-name-in-module,import-error import sys diff --git a/example/breeze_theme.py b/example/breeze_theme.py index bd95085..f50ca02 100644 --- a/example/breeze_theme.py +++ b/example/breeze_theme.py @@ -41,6 +41,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ''' +# pylint: disable=import-error,no-member + import typing import ctypes import ctypes.util @@ -113,7 +115,7 @@ def is_light_color(r: int, g: int, b: int) -> bool: def _get_theme_windows() -> Theme: '''Get the current theme, as light or dark, for the system on Windows.''' - from winreg import HKEY_CURRENT_USER, OpenKey, QueryValueEx + from winreg import HKEY_CURRENT_USER, OpenKey, QueryValueEx # pyright: ignore[reportAttributeAccessIssue] # In HKEY_CURRENT_USER, get the Personalisation Key. try: @@ -129,7 +131,7 @@ def _get_theme_windows() -> Theme: # https://learn.microsoft.com/en-us/windows/apps/desktop/modernize/ui/apply-windows-themes#know-when-dark-mode-is-enabled # noqa # pylint: disable=line-too-long # # Note that the documentation is inverted: if the foreground is light, we are using DARK mode. - winver = sys.getwindowsversion() + winver = sys.getwindowsversion() # pyright: ignore[reportAttributeAccessIssue] if winver[:4] < (10, 0, 10240, 0): return Theme.UNKNOWN try: @@ -160,6 +162,7 @@ def _listener_windows(callback: CallbackFn) -> None: if _advapi32 is None: _advapi32 = _initialize_advapi32() advapi32 = _advapi32 + assert advapi32 is not None hkey = ctypes.wintypes.HKEY() advapi32.RegOpenKeyExA( @@ -203,12 +206,12 @@ def _listener_windows(callback: CallbackFn) -> None: callback(Theme.LIGHT if query_value.value else Theme.DARK) -def _initialize_advapi32() -> 'ctypes.WinDLL': +def _initialize_advapi32() -> ctypes.CDLL: '''Initialize our advapi32 library.''' import ctypes.wintypes # pyright: ignore[reportMissingImports] # pylint: disable=redefined-outer-name - advapi32 = ctypes.windll.advapi32 + advapi32 = ctypes.windll.advapi32 # pyright: ignore[reportAttributeAccessIssue] # LSTATUS RegOpenKeyExA( # HKEY hKey, @@ -263,7 +266,7 @@ def _initialize_advapi32() -> 'ctypes.WinDLL': return advapi32 -_advapi32: typing.Optional['ctypes.WinDLL'] = None +_advapi32: typing.Optional['ctypes.CDLL'] = None # endregion diff --git a/example/shared.py b/example/shared.py index a3a24a7..a305385 100644 --- a/example/shared.py +++ b/example/shared.py @@ -5,6 +5,8 @@ Shared imports and compatibility definitions between Qt5 and Qt6. ''' +# pylint: disable=import-error + import argparse import importlib import logging