Skip to content

Commit

Permalink
Fix our linters for non-Windows systems.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexhuszagh committed Sep 7, 2024
1 parent 825cfa0 commit c55313a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion example/advanced-dock.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
13 changes: 8 additions & 5 deletions example/breeze_theme.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -263,7 +266,7 @@ def _initialize_advapi32() -> 'ctypes.WinDLL':
return advapi32


_advapi32: typing.Optional['ctypes.WinDLL'] = None
_advapi32: typing.Optional['ctypes.CDLL'] = None

# endregion

Expand Down
2 changes: 2 additions & 0 deletions example/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
Shared imports and compatibility definitions between Qt5 and Qt6.
'''

# pylint: disable=import-error

import argparse
import importlib
import logging
Expand Down

0 comments on commit c55313a

Please sign in to comment.