1414import winKernel
1515import config
1616
17- from ctypes import *
17+ from ctypes import * # noqa: F403
1818from ctypes import (
1919 WINFUNCTYPE ,
2020 c_bool ,
2626 create_unicode_buffer ,
2727 windll ,
2828)
29- from ctypes .wintypes import *
29+ from ctypes .wintypes import * # noqa: F403
3030from comtypes import BSTR
3131import winUser
3232import eventHandler
6666
6767#utility function to point an exported function pointer in a dll to a ctypes wrapped python function
6868def _setDllFuncPointer (dll ,name ,cfunc ):
69- cast (getattr (dll ,name ),POINTER (c_void_p )).contents .value = cast (cfunc ,c_void_p ).value
69+ cast (getattr (dll ,name ),POINTER (c_void_p )).contents .value = cast (cfunc ,c_void_p ).value # noqa: F405
7070
7171#Implementation of nvdaController methods
7272@WINFUNCTYPE (c_long ,c_wchar_p )
@@ -190,35 +190,35 @@ def nvdaController_brailleMessage(text: str) -> SystemErrorCodes:
190190def _lookupKeyboardLayoutNameWithHexString (layoutString ):
191191 buf = create_unicode_buffer (1024 )
192192 bufSize = c_int (2048 )
193- key = HKEY ()
194- if windll .advapi32 .RegOpenKeyExW (winreg .HKEY_LOCAL_MACHINE ,u"SYSTEM\\ CurrentControlSet\\ Control\\ Keyboard Layouts\\ " + layoutString ,0 ,winreg .KEY_QUERY_VALUE ,byref (key ))== 0 :
193+ key = HKEY () # noqa: F405
194+ if windll .advapi32 .RegOpenKeyExW (winreg .HKEY_LOCAL_MACHINE ,u"SYSTEM\\ CurrentControlSet\\ Control\\ Keyboard Layouts\\ " + layoutString ,0 ,winreg .KEY_QUERY_VALUE ,byref (key ))== 0 : # noqa: F405
195195 try :
196- if windll .advapi32 .RegQueryValueExW (key ,u"Layout Display Name" ,0 ,None ,buf ,byref (bufSize ))== 0 :
196+ if windll .advapi32 .RegQueryValueExW (key ,u"Layout Display Name" ,0 ,None ,buf ,byref (bufSize ))== 0 : # noqa: F405
197197 windll .shlwapi .SHLoadIndirectString (buf .value ,buf ,1023 ,None )
198198 return buf .value
199- if windll .advapi32 .RegQueryValueExW (key ,u"Layout Text" ,0 ,None ,buf ,byref (bufSize ))== 0 :
199+ if windll .advapi32 .RegQueryValueExW (key ,u"Layout Text" ,0 ,None ,buf ,byref (bufSize ))== 0 : # noqa: F405
200200 return buf .value
201201 finally :
202202 windll .advapi32 .RegCloseKey (key )
203203
204204@WINFUNCTYPE (c_long ,c_wchar_p )
205205def nvdaControllerInternal_requestRegistration (uuidString ):
206206 pid = c_long ()
207- windll .rpcrt4 .I_RpcBindingInqLocalClientPID (None ,byref (pid ))
207+ windll .rpcrt4 .I_RpcBindingInqLocalClientPID (None ,byref (pid )) # noqa: F405
208208 pid = pid .value
209209 if not pid :
210210 log .error ("Could not get process ID for RPC call" )
211- return - 1 ;
211+ return - 1
212212 bindingHandle = c_long ()
213213 bindingHandle .value = localLib .createRemoteBindingHandle (uuidString )
214214 if not bindingHandle :
215215 log .error ("Could not bind to inproc rpc server for pid %d" % pid )
216216 return - 1
217217 registrationHandle = c_long ()
218- res = localLib .nvdaInProcUtils_registerNVDAProcess (bindingHandle ,byref (registrationHandle ))
218+ res = localLib .nvdaInProcUtils_registerNVDAProcess (bindingHandle ,byref (registrationHandle )) # noqa: F405
219219 if res != 0 or not registrationHandle :
220220 log .error ("Could not register NVDA with inproc rpc server for pid %d, res %d, registrationHandle %s" % (pid ,res ,registrationHandle ))
221- windll .rpcrt4 .RpcBindingFree (byref (bindingHandle ))
221+ windll .rpcrt4 .RpcBindingFree (byref (bindingHandle )) # noqa: F405
222222 return - 1
223223 import appModuleHandler
224224 queueHandler .queueFunction (queueHandler .eventQueue ,appModuleHandler .update ,pid ,helperLocalBindingHandle = bindingHandle ,inprocRegistrationHandle = registrationHandle )
@@ -275,7 +275,7 @@ def nvdaControllerInternal_drawFocusRectNotify(hwnd, left, top, right, bottom):
275275 focus = api .getFocusObject ()
276276 if isinstance (focus ,Window ) and hwnd == focus .windowHandle :
277277 eventHandler .queueEvent ("displayModel_drawFocusRectNotify" ,focus ,rect = (left ,top ,right ,bottom ))
278- return 0 ;
278+ return 0
279279
280280@WINFUNCTYPE (c_long ,c_long ,c_long ,c_wchar_p )
281281def nvdaControllerInternal_logMessage (level ,pid ,message ):
@@ -373,7 +373,7 @@ def nvdaControllerInternal_inputCompositionUpdate(compositionString,selectionSta
373373def handleInputCandidateListUpdate (candidatesString ,selectionIndex ,inputMethod ):
374374 candidateStrings = candidatesString .split ('\n ' )
375375 import speech
376- from NVDAObjects .inputComposition import InputComposition , CandidateList , CandidateItem
376+ from NVDAObjects .inputComposition import CandidateItem
377377 focus = api .getFocusObject ()
378378 if not (0 <= selectionIndex < len (candidateStrings )):
379379 if isinstance (focus ,CandidateItem ):
@@ -452,7 +452,7 @@ def handleInputConversionModeUpdate(oldFlags,newFlags,lcid):
452452 for x in range (32 ):
453453 x = 2 ** x
454454 msgs = inputConversionModeMessages .get (x )
455- if not msgs : continue
455+ if not msgs : continue # noqa: E701
456456 newOn = bool (newFlags & x )
457457 oldOn = bool (oldFlags & x )
458458 if newOn != oldOn :
@@ -523,7 +523,7 @@ def nvdaControllerInternal_inputLangChangeNotify(threadID,hkl,layoutString):
523523 layoutStringCodes .append (stringCode [0 :4 ].rjust (8 ,'0' ))
524524 for stringCode in layoutStringCodes :
525525 inputMethodName = _lookupKeyboardLayoutNameWithHexString (stringCode )
526- if inputMethodName : break
526+ if inputMethodName : break # noqa: E701
527527 if not inputMethodName :
528528 log .debugWarning ("Could not find layout name for keyboard layout, reporting as unknown" )
529529 # Translators: The label for an unknown input method when switching input methods.
@@ -642,7 +642,7 @@ def initialize() -> None:
642642 res = windll .User32 .GetKeyboardLayoutNameW (buf )
643643 if res :
644644 lastLayoutString = buf .value
645- localLib = cdll .LoadLibrary (os .path .join (versionedLibPath ,'nvdaHelperLocal.dll' ))
645+ localLib = cdll .LoadLibrary (os .path .join (versionedLibPath ,'nvdaHelperLocal.dll' )) # noqa: F405
646646 for name ,func in [
647647 ("nvdaController_speakText" ,nvdaController_speakText ),
648648 ("nvdaController_speakSsml" , nvdaController_speakSsml ),
@@ -670,14 +670,14 @@ def initialize() -> None:
670670 raise e
671671 localLib .nvdaHelperLocal_initialize (globalVars .appArgs .secure )
672672 generateBeep = localLib .generateBeep
673- generateBeep .argtypes = [c_char_p ,c_float ,c_int ,c_int ,c_int ]
673+ generateBeep .argtypes = [c_char_p ,c_float ,c_int ,c_int ,c_int ] # noqa: F405
674674 generateBeep .restype = c_int
675675 onSsmlMarkReached = localLib .nvdaController_onSsmlMarkReached
676676 onSsmlMarkReached .argtypes = [c_wchar_p ]
677677 onSsmlMarkReached .restype = c_ulong
678678 # The rest of this function (to do with injection) only applies if NVDA is not running as a Windows store application
679679 # Handle VBuf_getTextInRange's BSTR out parameter so that the BSTR will be freed automatically.
680- VBuf_getTextInRange = CFUNCTYPE (c_int , c_int , c_int , c_int , POINTER (BSTR ), c_int )(
680+ VBuf_getTextInRange = CFUNCTYPE (c_int , c_int , c_int , c_int , POINTER (BSTR ), c_int )( # noqa: F405
681681 ("VBuf_getTextInRange" , localLib ),
682682 ((1 ,), (1 ,), (1 ,), (2 ,), (1 ,)))
683683 if config .isAppX :
@@ -693,9 +693,9 @@ def initialize() -> None:
693693 winKernel .LOAD_WITH_ALTERED_SEARCH_PATH
694694 )
695695 if not h :
696- log .critical ("Error loading nvdaHelperRemote.dll: %s" % WinError ())
696+ log .critical ("Error loading nvdaHelperRemote.dll: %s" % WinError ()) # noqa: F405
697697 return
698- _remoteLib = CDLL ("nvdaHelperRemote" ,handle = h )
698+ _remoteLib = CDLL ("nvdaHelperRemote" ,handle = h ) # noqa: F405
699699 if _remoteLib .injection_initialize () == 0 :
700700 raise RuntimeError ("Error initializing NVDAHelperRemote" )
701701 if not _remoteLib .installIA2Support ():
@@ -749,6 +749,6 @@ def bstrReturn(address):
749749 # Just access the string ourselves.
750750 # This will terminate at a null character, even though BSTR allows nulls.
751751 # We're only using this for normal, null-terminated strings anyway.
752- val = wstring_at (address )
752+ val = wstring_at (address ) # noqa: F405
753753 windll .oleaut32 .SysFreeString (address )
754754 return val
0 commit comments