From b5a4ee6ed2f60c68cec307e9bcd946d6440fc0b7 Mon Sep 17 00:00:00 2001 From: David Sangrey Date: Thu, 28 Mar 2024 10:49:01 -0400 Subject: [PATCH] [Nit] Cleanup some Flake8 --- config/__init__.py | 1 - plugins/eddn.py | 1 - protocol.py | 36 ++++++++++++++++++------------------ tests/config/_old_config.py | 6 +++--- 4 files changed, 21 insertions(+), 23 deletions(-) diff --git a/config/__init__.py b/config/__init__.py index 99e8fdc6..d85956a7 100644 --- a/config/__init__.py +++ b/config/__init__.py @@ -467,7 +467,6 @@ def get_config(*args, **kwargs) -> AbstractConfig: :param kwargs: Args to be passed through to implementation. :return: Instance of the implementation. """ - if sys.platform == "win32": # pragma: sys-platform-win32 from .windows import WinConfig return WinConfig(*args, **kwargs) diff --git a/plugins/eddn.py b/plugins/eddn.py index b7133725..6345f579 100644 --- a/plugins/eddn.py +++ b/plugins/eddn.py @@ -27,7 +27,6 @@ import os import pathlib import re import sqlite3 -import sys import tkinter as tk from platform import system from textwrap import dedent diff --git a/protocol.py b/protocol.py index 0f1c157f..4c9e41ca 100644 --- a/protocol.py +++ b/protocol.py @@ -26,6 +26,7 @@ is_wine = False if sys.platform == 'win32': from ctypes import windll # type: ignore + try: if windll.ntdll.wine_get_version: is_wine = True @@ -58,13 +59,13 @@ class GenericProtocolHandler: self.master.event_generate('<>', when="tail") -if (config.auth_force_edmc_protocol - or ( - sys.platform == 'win32' - and getattr(sys, 'frozen', False) - and not is_wine - and not config.auth_force_localserver - )): +if (config.auth_force_edmc_protocol # noqa: C901 + or ( + sys.platform == 'win32' + and getattr(sys, 'frozen', False) + and not is_wine + and not config.auth_force_localserver + )): # This could be false if you use auth_force_edmc_protocol, but then you get to keep the pieces assert sys.platform == 'win32' # spell-checker: words HBRUSH HICON WPARAM wstring WNDCLASS HMENU HGLOBAL @@ -186,11 +187,11 @@ if (config.auth_force_edmc_protocol # which we can read out as shown below, and then compare. target_is_valid = lparam_low == 0 or ( - GlobalGetAtomNameW(lparam_low, service, 256) and service.value == appname + GlobalGetAtomNameW(lparam_low, service, 256) and service.value == appname ) topic_is_valid = lparam_high == 0 or ( - GlobalGetAtomNameW(lparam_high, topic, 256) and topic.value.lower() == 'system' + GlobalGetAtomNameW(lparam_high, topic, 256) and topic.value.lower() == 'system' ) if target_is_valid and topic_is_valid: @@ -251,15 +252,15 @@ if (config.auth_force_edmc_protocol # https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-createwindowexw hwnd = CreateWindowExW( - 0, # dwExStyle + 0, # dwExStyle wndclass.lpszClassName, # lpClassName - "DDE Server", # lpWindowName - 0, # dwStyle + "DDE Server", # lpWindowName + 0, # dwStyle CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, # X, Y, nWidth, nHeight self.master.winfo_id(), # hWndParent # Don't use HWND_MESSAGE since the window won't get DDE broadcasts - None, # hMenu - wndclass.hInstance, # hInstance - None # lpParam + None, # hMenu + wndclass.hInstance, # hInstance + None # lpParam ) msg = MSG() @@ -421,10 +422,9 @@ def get_handler_impl() -> Type[GenericProtocolHandler]: :return: An instantiatable GenericProtocolHandler """ - if ( - (sys.platform == 'win32' and config.auth_force_edmc_protocol) - or (getattr(sys, 'frozen', False) and not is_wine and not config.auth_force_localserver) + (sys.platform == 'win32' and config.auth_force_edmc_protocol) + or (getattr(sys, 'frozen', False) and not is_wine and not config.auth_force_localserver) ): return WindowsProtocolHandler diff --git a/tests/config/_old_config.py b/tests/config/_old_config.py index 35ae19e3..2b5244b6 100644 --- a/tests/config/_old_config.py +++ b/tests/config/_old_config.py @@ -5,8 +5,8 @@ import numbers import sys import warnings from configparser import NoOptionError -from os import getenv, makedirs, mkdir, pardir -from os.path import dirname, expanduser, isdir, join, normpath +from os import getenv, makedirs, mkdir +from os.path import dirname, expanduser, isdir, join from typing import TYPE_CHECKING from config import applongname, appname, update_interval from EDMCLogging import get_main_logger @@ -109,7 +109,7 @@ class OldConfig: OUT_EDDN_DELAY = 4096 OUT_STATION_ANY = OUT_EDDN_SEND_STATION_DATA | OUT_MKT_TD | OUT_MKT_CSV - if sys.platform == 'win32': + if sys.platform == 'win32': # noqa: C901 def __init__(self): self.app_dir = join(known_folder_path(FOLDERID_LocalAppData), appname) # type: ignore