Skip to content

Commit d747345

Browse files
committed
Remove legacy compatibility code for NVDA < 2024.1
- Remove NVDA version checks (buildVersion / NVDA_VERSION < "2023.2") - Remove dead code for NVDA 2014.4 (searchTag_2014, nextTag, previousTag, searchTag wrapper) - Remove Python version_info < 9 guards, use collections.abc directly - Remove unnecessary try/except imports (json, VBuf_getTextInRange) - Remove hasattr guard for addon.isDisabled (available since NVDA 2016.3) - Clean up unused imports (sys, virtualBuffers, NVDAHelper, buildVersion)
1 parent fe5ada8 commit d747345

19 files changed

Lines changed: 23 additions & 221 deletions

File tree

addon/globalPlugins/webAccess/__init__.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@
6565
import addonHandler
6666
import api
6767
import baseObject
68-
from buildVersion import version_detailed as NVDA_VERSION
6968
import controlTypes
7069
import core
7170
import eventHandler
@@ -356,12 +355,7 @@ def script_showWebAccessSettings(self, gesture): # @UnusedVariable
356355
# After the above import, it appears that the `gui` name now points to the `.gui` module
357356
# rather than NVDA's `gui`… No clue why…
358357
import gui
359-
if NVDA_VERSION < "2023.2":
360-
# Deprecated as of NVDA 2023.2
361-
gui.mainFrame._popupSettingsDialog(WebAccessSettingsDialog)
362-
else:
363-
# Now part of the public API as of NVDA PR #15121
364-
gui.mainFrame.popupSettingsDialog(WebAccessSettingsDialog)
358+
gui.mainFrame.popupSettingsDialog(WebAccessSettingsDialog)
365359

366360
@script(
367361
# Translators: Input help mode message for a WebAccess command

addon/globalPlugins/webAccess/gui/__init__.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,10 @@
2828

2929

3030
from abc import abstractmethod
31-
from buildVersion import version_detailed as NVDA_VERSION
3231
from collections import OrderedDict
3332
from dataclasses import dataclass
3433
from enum import Enum, auto
3534
import re
36-
import sys
3735
from typing import Any, Callable
3836
import wx
3937
import wx.lib.mixins.listctrl as listmix
@@ -61,11 +59,7 @@
6159
# Fall back to wx.lib.scrolledpanel.ScrolledPanel which now has the fix built-in.
6260
_TabbableScrolledPanel = getattr(nvdaControls, "TabbableScrolledPanel", ScrolledPanel)
6361

64-
65-
if sys.version_info[1] < 9:
66-
from typing import Iterable, Mapping, Sequence, Set
67-
else:
68-
from collections.abc import Iterable, Mapping, Sequence, Set
62+
from collections.abc import Iterable, Mapping, Sequence, Set
6963

7064

7165
addonHandler.initTranslation()
@@ -256,7 +250,7 @@ def _buildGui(self):
256250
self.SetSizer(self.mainSizer)
257251

258252

259-
# TODO: Consider migrating to NVDA's SettingsDialog once we hit 2023.2 as minimum version
253+
# TODO: Consider migrating to NVDA's SettingsDialog
260254
class ContextualDialog(ScalingMixin, wx.Dialog):
261255

262256
def initData(self, context):
@@ -372,12 +366,9 @@ def configuredSettingsDialogType(hasApplyButton: bool) -> type(SettingsDialog):
372366
class Type(SettingsDialog):
373367

374368
def __init__(self, *args, **kwargs):
375-
if NVDA_VERSION < "2023.2":
376-
kwargs["hasApplyButton"] = hasApplyButton
377-
else:
378-
buttons: Set[int] = kwargs.get("buttons", {wx.OK, wx.CANCEL})
379-
if not hasApplyButton:
380-
buttons -= {wx.APPLY}
369+
buttons: Set[int] = kwargs.get("buttons", {wx.OK, wx.CANCEL})
370+
if not hasApplyButton:
371+
buttons -= {wx.APPLY}
381372
super().__init__(*args, **kwargs)
382373

383374
return Type

addon/globalPlugins/webAccess/gui/rule/__init__.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
__author__ = "Julien Cochuyt <j.cochuyt@accessolutions.fr>"
2424

2525

26-
import sys
2726
from typing import Any
2827

2928
import wx
@@ -37,11 +36,7 @@
3736
from ...utils import updateOrDrop
3837
from .properties import Properties
3938

40-
41-
if sys.version_info[1] < 9:
42-
from typing import Mapping
43-
else:
44-
from collections.abc import Mapping
39+
from collections.abc import Mapping
4540

4641

4742
addonHandler.initTranslation()

addon/globalPlugins/webAccess/gui/rule/criteriaEditor.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
from collections import OrderedDict
3434
from copy import deepcopy
3535
import re
36-
import sys
3736
from typing import Any
3837
import wx
3938
from wx.lib.expando import EVT_ETC_LAYOUT_NEEDED, ExpandoTextCtrl
@@ -66,11 +65,7 @@
6665
from .gestures import GesturesPanelBase
6766
from .properties import Properties, PropertiesPanelBase, Property
6867

69-
70-
if sys.version_info[1] < 9:
71-
from typing import Mapping, Sequence
72-
else:
73-
from collections.abc import Mapping, Sequence
68+
from collections.abc import Mapping, Sequence
7469

7570

7671
addonHandler.initTranslation()

addon/globalPlugins/webAccess/gui/rule/editor.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
from dataclasses import dataclass
3636
from enum import Enum
3737
from functools import partial
38-
import sys
3938
from typing import Any
4039
import wx
4140
from wx.lib.expando import EVT_ETC_LAYOUT_NEEDED, ExpandoTextCtrl
@@ -80,11 +79,7 @@
8079
SinglePropertyEditorPanelBase,
8180
)
8281

83-
84-
if sys.version_info[1] < 9:
85-
from typing import Mapping, Sequence
86-
else:
87-
from collections.abc import Mapping, Sequence
82+
from collections.abc import Mapping, Sequence
8883

8984

9085
addonHandler.initTranslation()

addon/globalPlugins/webAccess/gui/rule/gestureBinding.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
)
3131

3232

33-
import sys
3433
from typing import Any
3534
import wx
3635

@@ -45,11 +44,7 @@
4544
from ...utils import guarded, logException
4645
from .. import ScalingMixin, showContextualDialog
4746

48-
49-
if sys.version_info[1] < 9:
50-
from typing import Mapping
51-
else:
52-
from collections.abc import Mapping
47+
from collections.abc import Mapping
5348

5449

5550
addonHandler.initTranslation()

addon/globalPlugins/webAccess/gui/rule/gestures.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
)
3030

3131

32-
import sys
3332
from typing import Any
3433
import wx
3534

@@ -44,11 +43,7 @@
4443
from . import gestureBinding
4544
from .abc import RuleAwarePanelBase
4645

47-
48-
if sys.version_info[1] < 9:
49-
from typing import Mapping
50-
else:
51-
from collections.abc import Mapping
46+
from collections.abc import Mapping
5247

5348

5449
addonHandler.initTranslation()

addon/globalPlugins/webAccess/gui/rule/manager.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030

3131

3232
from collections import namedtuple
33-
import sys
3433
import wx
3534

3635
import addonHandler
@@ -47,11 +46,7 @@
4746
from .. import ContextualDialog, showContextualDialog, stripAccel
4847
from .editor import getSummary
4948

50-
51-
if sys.version_info[1] < 9:
52-
from typing import Mapping
53-
else:
54-
from collections.abc import Mapping
49+
from collections.abc import Mapping
5550

5651

5752
addonHandler.initTranslation()

addon/globalPlugins/webAccess/gui/rule/properties.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
from collections import ChainMap
3232
from abc import abstractmethod
3333
from enum import Enum
34-
import sys
3534
from typing import Any
3635
import wx
3736

@@ -46,11 +45,7 @@
4645
from ...utils import guarded, logException, updateOrDrop
4746
from .. import ContextualSettingsPanel, EditorType, ListCtrlAutoWidth, SingleFieldEditorMixin
4847

49-
50-
if sys.version_info[1] < 9:
51-
from typing import Iterator, Mapping
52-
else:
53-
from collections.abc import Iterator, Mapping
48+
from collections.abc import Iterator, Mapping
5449

5550

5651
addonHandler.initTranslation()

addon/globalPlugins/webAccess/gui/webModule/__init__.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@
2323
__author__ = "Julien Cochuyt <j.cochuyt@accessolutions.fr>"
2424

2525

26-
import sys
27-
from typing import Any
28-
2926
import os
3027
import wx
3128

@@ -36,12 +33,6 @@
3633
from ...webModuleHandler import WebModule
3734

3835

39-
if sys.version_info[1] < 9:
40-
from typing import Mapping
41-
else:
42-
from collections.abc import Mapping
43-
44-
4536
addonHandler.initTranslation()
4637

4738

0 commit comments

Comments
 (0)