diff --git a/protocol.py b/protocol.py index 27391498..290a7031 100644 --- a/protocol.py +++ b/protocol.py @@ -1,5 +1,4 @@ """protocol handler for cAPI authorisation.""" - # spell-checker: words ntdll GURL alloc wfile instantiatable pyright import os import sys @@ -35,7 +34,7 @@ class GenericProtocolHandler: def __init__(self) -> None: self.redirect = protocolhandler_redirect # Base redirection URL self.master: 'tkinter.Tk' = None # type: ignore - self.lastpayload = None + self.lastpayload: Optional[str] = None def start(self, master: 'tkinter.Tk') -> None: """Start Protocol Handler.""" @@ -45,7 +44,7 @@ class GenericProtocolHandler: """Stop / Close Protocol Handler.""" pass - def event(self, url) -> None: + def event(self, url: str) -> None: """Generate an auth event.""" self.lastpayload = url @@ -197,7 +196,7 @@ elif (config.auth_force_edmc_protocol # Windows Message handler stuff (IPC) # https://docs.microsoft.com/en-us/previous-versions/windows/desktop/legacy/ms633573(v=vs.85) @WINFUNCTYPE(c_long, HWND, UINT, WPARAM, LPARAM) - def WndProc(hwnd: HWND, message: UINT, wParam, lParam): # noqa: N803 N802 + def WndProc(hwnd: HWND, message: UINT, wParam: WPARAM, lParam: LPARAM) -> c_long: # noqa: N803 N802 """ Deal with DDE requests. @@ -216,8 +215,10 @@ elif (config.auth_force_edmc_protocol topic = create_unicode_buffer(256) # Note that lParam is 32 bits, and broken into two 16 bit words. This will break on 64bit as the math is # wrong - lparam_low = lParam & 0xFFFF # if nonzero, the target application for which a conversation is requested - lparam_high = lParam >> 16 # if nonzero, the topic of said conversation + # if nonzero, the target application for which a conversation is requested + lparam_low = lParam & 0xFFFF # type: ignore + # if nonzero, the topic of said conversation + lparam_high = lParam >> 16 # type: ignore # if either of the words are nonzero, they contain # atoms https://docs.microsoft.com/en-us/windows/win32/dataxchg/about-atom-tables @@ -237,7 +238,10 @@ elif (config.auth_force_edmc_protocol wParam, WM_DDE_ACK, hwnd, PackDDElParam(WM_DDE_ACK, GlobalAddAtomW(appname), GlobalAddAtomW('System')) ) - return 0 + # It works as a constructor as per + return c_long(0) + + return c_long(1) # This is an utter guess -Ath class WindowsProtocolHandler(GenericProtocolHandler): """ @@ -350,7 +354,7 @@ else: # Linux / Run from source self.thread: Optional[threading.Thread] = None - def start(self, master) -> None: + def start(self, master: 'tkinter.Tk') -> None: """Start the HTTP server thread.""" GenericProtocolHandler.start(self, master) self.thread = threading.Thread(target=self.worker, name='OAuth worker') @@ -412,7 +416,7 @@ else: # Linux / Run from source else: self.end_headers() - def log_request(self, code, size=None): + def log_request(self, code: int | str = '-', size: int | str = '-') -> None: """Override to prevent logging.""" pass