Skip to content

Commit b8456ff

Browse files
authored
Merge a8e33c0 into f863a09
2 parents f863a09 + a8e33c0 commit b8456ff

File tree

153 files changed

+1293
-1377
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

153 files changed

+1293
-1377
lines changed

.git-blame-ignore-revs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@ e6a639bfe237ff7f98c4cbec2094a34ac4b879db
88
7afafc698a0c5e6689701f024764ca525acf50af
99
# Normalize all line endings
1010
8fb8ffcaba3950b1e4ca7b58e165267fc5369eb9
11+
# Lint the repository with Ruff
12+
d3ce6b8879b14464058d5eaf3f914f803e8f22ac
13+
8bdfbc2e8da78945e20c3b203b39b9a81227d596

appveyor/mozillaSyms.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
To update the list of symbols uploaded to Mozilla, see the DLL_NAMES constant below.
77
"""
88

9-
import argparse
109
import os
1110
import subprocess
1211
import sys

site_scons/site_tools/doxygen.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ def DoxyfileParse(file_contents):
4747
lex.whitespace = lex.whitespace.replace("\n", "")
4848
lex.escape = ""
4949

50-
lineno = lex.lineno
50+
lineno = lex.lineno # noqa: F841
5151
token = lex.get_token()
5252
key = token # the first token should be a key
5353
last_token = ""
5454
key_token = False
55-
next_key = False
55+
next_key = False # noqa: F841
5656
new_data = True
5757

5858
def append_data(data, key, new_data, token):

site_scons/site_tools/gettextTool.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
###
1414

1515
import os
16-
import sys
1716

1817
# Get the path to msgfmt.
1918
MSGFMT = os.path.abspath(os.path.join("miscDeps", "tools", "msgfmt.exe"))

site_scons/site_tools/msrpc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def exists(env):
7575
return midl.exists(env)
7676

7777
def generate(env):
78-
if not 'MIDL' in env:
78+
if 'MIDL' not in env:
7979
from SCons.Tool import midl
8080
midl.generate(env)
8181
env['BUILDERS']['MSRPCStubs']=MSRPCStubs_builder

site_scons/site_tools/recursiveInstall.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def RecursiveInstall(env, target, dir):
5151
dir = env.Dir(dir).abspath
5252
target = env.Dir(target).abspath
5353

54-
l = len(dir) + 1
54+
l = len(dir) + 1 # noqa: E741
5555

5656
relnodes = [ n.abspath[l:] for n in nodes ]
5757

source/JABHandler.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ def internal_getWindowHandleFromAccContext(vmID,accContext):
390390
return bridgeDll.getHWNDFromAccessibleContext(vmID,topAC)
391391
finally:
392392
bridgeDll.releaseJavaObject(vmID,topAC)
393-
except:
393+
except: # noqa: E722
394394
return None
395395

396396
def getWindowHandleFromAccContext(vmID,accContext):
@@ -421,7 +421,7 @@ def __del__(self):
421421
if isRunning:
422422
try:
423423
bridgeDll.releaseJavaObject(self.vmID,self.accContext)
424-
except:
424+
except: # noqa: E722
425425
log.debugWarning("Error releasing java object",exc_info=True)
426426

427427

@@ -795,15 +795,15 @@ def enterJavaWindow_helper(hwnd):
795795
while time.time()<timeout and not eventHandler.isPendingEvents("gainFocus"):
796796
try:
797797
bridgeDll.getAccessibleContextWithFocus(hwnd,byref(vmID),byref(accContext))
798-
except:
798+
except: # noqa: E722
799799
pass
800800
if vmID and accContext:
801801
break
802802
time.sleep(0.01)
803803
if not vmID or not accContext:
804804
try:
805805
bridgeDll.getAccessibleContextFromHWND(hwnd,byref(vmID),byref(accContext))
806-
except:
806+
except: # noqa: E722
807807
return
808808
vmID=vmID.value
809809
vmIDsToWindowHandles[vmID]=hwnd

source/NVDAHelper.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import winKernel
1515
import config
1616

17-
from ctypes import *
17+
from ctypes import * # noqa: F403
1818
from ctypes import (
1919
WINFUNCTYPE,
2020
c_bool,
@@ -26,7 +26,7 @@
2626
create_unicode_buffer,
2727
windll,
2828
)
29-
from ctypes.wintypes import *
29+
from ctypes.wintypes import * # noqa: F403
3030
from comtypes import BSTR
3131
import winUser
3232
import eventHandler
@@ -66,7 +66,7 @@
6666

6767
#utility function to point an exported function pointer in a dll to a ctypes wrapped python function
6868
def _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:
190190
def _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)
205205
def 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)
281281
def nvdaControllerInternal_logMessage(level,pid,message):
@@ -373,7 +373,7 @@ def nvdaControllerInternal_inputCompositionUpdate(compositionString,selectionSta
373373
def 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

source/NVDAObjects/IAccessible/MSHTML.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#This file is covered by the GNU General Public License.
55
#See the file COPYING for more details.
66

7-
import time
87
from comtypes import COMError
98
import comtypes.client
109
import comtypes.automation
@@ -194,7 +193,7 @@ def locateHTMLElementByID(document,ID):
194193
else: #probably IE 10 in standards mode (#3151)
195194
try:
196195
element=document.all.item(ID)
197-
except:
196+
except: # noqa: E722
198197
element=None
199198
if element is None: #getElementsByName doesn't return element with specified ID in IE11 (#5784)
200199
try:
@@ -230,7 +229,7 @@ def locateHTMLElementByID(document,ID):
230229
if not childElement:
231230
continue
232231
childElement=locateHTMLElementByID(childElement.document,ID)
233-
if not childElement: continue
232+
if not childElement: continue # noqa: E701
234233
return childElement
235234

236235
def getChildHTMLNodeFromFrame(frame):
@@ -241,7 +240,7 @@ def getChildHTMLNodeFromFrame(frame):
241240
# In this case, just skip this frame.
242241
return
243242
res=IAccessibleHandler.accChild(pacc,1)
244-
if not res: return
243+
if not res: return # noqa: E701
245244
return HTMLNodeFromIAccessible(res[0])
246245

247246
class MSHTMLTextInfo(textInfos.TextInfo):
@@ -298,7 +297,7 @@ def __init__(self,obj,position,_rangeObj=None):
298297
return
299298
try:
300299
editableBody=self.obj.HTMLNodeName=="BODY" and self.obj.isContentEditable
301-
except:
300+
except: # noqa: E722
302301
editableBody=False
303302
if editableBody:
304303
self._rangeObj=self.obj.HTMLNode.document.selection.createRange()
@@ -443,7 +442,7 @@ def suspendCaretEvents(self):
443442
self._ignoreCaretEvents=oldVal
444443

445444
def event_caret(self):
446-
if self._ignoreCaretEvents: return
445+
if self._ignoreCaretEvents: return # noqa: E701
447446
if self.TextInfo is not MSHTMLTextInfo and not self._UIAControl:
448447
return
449448
try:
@@ -475,7 +474,7 @@ def kwargsFromSuper(cls,kwargs,relation=None):
475474
while True:
476475
try:
477476
HTMLNode=HTMLNode.document.activeElement
478-
except:
477+
except: # noqa: E722
479478
log.exception("Error getting activeElement")
480479
break
481480
nodeName=HTMLNode.nodeName or ""
@@ -496,7 +495,7 @@ def kwargsFromSuper(cls,kwargs,relation=None):
496495
xFactor,yFactor=getZoomFactorsFromHTMLDocument(HTMLNode.document)
497496
try:
498497
HTMLNode=HTMLNode.document.elementFromPoint(p.x // xFactor, p.y // yFactor)
499-
except:
498+
except: # noqa: E722
500499
HTMLNode=None
501500
if not HTMLNode:
502501
log.debugWarning("Error getting HTMLNode with elementFromPoint")
@@ -847,7 +846,7 @@ def _get_states(self):
847846
def _get_isContentEditable(self):
848847
try:
849848
return bool(self.HTMLNode.isContentEditable)
850-
except:
849+
except: # noqa: E722
851850
return False
852851

853852
def _get_parent(self):
@@ -936,7 +935,7 @@ def _get_columnNumber(self):
936935
raise NotImplementedError
937936
try:
938937
return self.HTMLNode.cellIndex+1
939-
except:
938+
except: # noqa: E722
940939
raise NotImplementedError
941940

942941
def _get_rowNumber(self):
@@ -946,7 +945,7 @@ def _get_rowNumber(self):
946945
while HTMLNode:
947946
try:
948947
return HTMLNode.rowIndex+1
949-
except:
948+
except: # noqa: E722
950949
pass
951950
HTMLNode=HTMLNode.parentNode
952951
raise NotImplementedError
@@ -956,7 +955,7 @@ def _get_rowCount(self):
956955
raise NotImplementedError
957956
try:
958957
return len([x for x in self.HTMLNode.rows])
959-
except:
958+
except: # noqa: E722
960959
raise NotImplementedError
961960

962961
def scrollIntoView(self):
@@ -1008,7 +1007,7 @@ def _get_table(self):
10081007
nodeName=HTMLNode.nodeName
10091008
if nodeName:
10101009
nodeName=nodeName.upper()
1011-
if nodeName=="TABLE": return MSHTML(HTMLNode=HTMLNode)
1010+
if nodeName=="TABLE": return MSHTML(HTMLNode=HTMLNode) # noqa: E701
10121011
HTMLNode=HTMLNode.parentNode
10131012
return None
10141013

0 commit comments

Comments
 (0)