Skip to content

Commit ca41910

Browse files
committed
Eliminate unused local variables
1 parent 0fe453c commit ca41910

7 files changed

+27
-21
lines changed

AddonManagerOptions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def recursive_widget_saver(self, widget):
9797
pref.SetString(str(pref_entry, "utf-8"), text)
9898
elif widget.metaObject().className() == "Gui::PrefFileChooser":
9999
filename = str(widget.property("fileName"))
100-
filename = pref.SetString(str(pref_entry, "utf-8"), filename)
100+
pref.SetString(str(pref_entry, "utf-8"), filename)
101101

102102
# Recurse over children
103103
if isinstance(widget, QtCore.QObject):

AddonManagerTest/app/test_licenses.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def tearDown(self) -> None:
3636
pass
3737

3838
def test_instantiate_license_manager(self):
39-
manager = addonmanager_licenses.SPDXLicenseManager()
39+
_ = addonmanager_licenses.SPDXLicenseManager()
4040
# Should not raise an exception...
4141

4242
def test_is_osi_approved(self):

AddonManagerTest/app/test_uninstaller.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ def test_uninstall_no_name(self):
9292
"""Test the integrated uninstall function for an addon without a name"""
9393

9494
with tempfile.TemporaryDirectory() as temp_dir:
95-
toplevel_path = self.setup_dummy_installation(temp_dir)
95+
_ = self.setup_dummy_installation(temp_dir)
9696
self.mock_addon.name = None
97-
result = self.test_object.run()
97+
_ = self.test_object.run()
9898
self.assertTrue(os.path.exists(temp_dir))
9999
self.assertIn("failure", self.signals_caught)
100100
self.assertNotIn("success", self.signals_caught)
@@ -104,9 +104,9 @@ def test_uninstall_dangerous_name(self):
104104
"""Test the integrated uninstall function for an addon with a dangerous name"""
105105

106106
with tempfile.TemporaryDirectory() as temp_dir:
107-
toplevel_path = self.setup_dummy_installation(temp_dir)
107+
_ = self.setup_dummy_installation(temp_dir)
108108
self.mock_addon.name = "./"
109-
result = self.test_object.run()
109+
_ = self.test_object.run()
110110
self.assertTrue(os.path.exists(temp_dir))
111111
self.assertIn("failure", self.signals_caught)
112112
self.assertNotIn("success", self.signals_caught)
@@ -116,9 +116,9 @@ def test_uninstall_unmatching_name(self):
116116
"""Test the integrated uninstall function for an addon with a name that isn't installed"""
117117

118118
with tempfile.TemporaryDirectory() as temp_dir:
119-
toplevel_path = self.setup_dummy_installation(temp_dir)
119+
_ = self.setup_dummy_installation(temp_dir)
120120
self.mock_addon.name += "Nonexistent"
121-
result = self.test_object.run()
121+
_ = self.test_object.run()
122122
self.assertTrue(os.path.exists(temp_dir))
123123
self.assertIn("failure", self.signals_caught)
124124
self.assertNotIn("success", self.signals_caught)
@@ -134,7 +134,7 @@ def test_uninstall_addon_with_macros(self):
134134
"FakeMacro.FCMacro",
135135
os.path.join(toplevel_path, "AM_INSTALLATION_DIGEST.txt"),
136136
)
137-
result = self.test_object.run()
137+
_ = self.test_object.run()
138138
self.assertNotIn("failure", self.signals_caught)
139139
self.assertIn("success", self.signals_caught)
140140
self.assertIn("finished", self.signals_caught)
@@ -155,9 +155,9 @@ def func(self, *args):
155155

156156
interceptor = Interceptor()
157157
with tempfile.TemporaryDirectory() as temp_dir:
158-
toplevel_path = self.setup_dummy_installation(temp_dir)
158+
_ = self.setup_dummy_installation(temp_dir)
159159
self.test_object.run_uninstall_script = interceptor.func
160-
result = self.test_object.run()
160+
_ = self.test_object.run()
161161
self.assertTrue(interceptor.called, "Failed to call uninstall script")
162162

163163
def test_remove_extra_files_no_digest(self):

AddonManagerTest/gui/test_installer_gui.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -392,11 +392,13 @@ def test_ask_for_toolbar_no_dialog_default_exists(self, toolbar_adapter):
392392
self.skipTest("Test not updated to handle running outside FreeCAD")
393393
preferences_settings = {
394394
"alwaysAskForToolbar": False,
395+
"FirstTimeAskingForToolbar": True,
395396
"CustomToolbarName": "UnitTestCustomToolbar",
396397
}
397398
preferences_replacement = fci.Preferences(preferences_settings)
398-
with patch("addonmanager_installer_gui.fci.Preferences") as preferences:
399-
preferences = lambda: preferences_replacement
399+
with patch(
400+
"addonmanager_installer_gui.fci.Preferences", return_value=preferences_replacement
401+
):
400402
result = self.installer._ask_for_toolbar([])
401403
self.assertIsNotNone(result)
402404
self.assertTrue(hasattr(result, "get"))
@@ -405,10 +407,14 @@ def test_ask_for_toolbar_no_dialog_default_exists(self, toolbar_adapter):
405407

406408
def test_ask_for_toolbar_with_dialog_cancelled(self):
407409
"""If the user cancels the dialog no toolbar is created"""
408-
preferences_settings = {"alwaysAskForToolbar": True}
410+
preferences_settings = {
411+
"alwaysAskForToolbar": True,
412+
"FirstTimeAskingForToolbar": True,
413+
}
409414
preferences_replacement = fci.Preferences(preferences_settings)
410-
with patch("addonmanager_installer_gui.fci.Preferences") as preferences:
411-
preferences = lambda: preferences_replacement
415+
with patch(
416+
"addonmanager_installer_gui.fci.Preferences", return_value=preferences_replacement
417+
):
412418
_ = DialogWatcher(
413419
translate("select_toolbar_dialog", "Select Toolbar"),
414420
QtWidgets.QDialogButtonBox.Cancel,
@@ -445,7 +451,7 @@ def test_ask_for_toolbar_with_dialog_selection(self, toolbar_adapter):
445451
# Third test: the user selects a custom toolbar in the dialog, and checks the box to always
446452
# ask.
447453
self.skipTest("Test not updated to handle running outside FreeCAD")
448-
dialog_interactor = DialogInteractor(
454+
_ = DialogInteractor(
449455
translate("select_toolbar_dialog", "Select Toolbar"),
450456
self.interactor_selection_option_and_checkbox,
451457
)

AddonManagerTest/gui/test_widget_addon_buttons.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ class TestWidgetAddonButtons(unittest.TestCase):
3333
def test_instantiation(self):
3434
window = QtWidgets.QDialog()
3535
window.setObjectName("Test Widget Addon Buttons")
36-
_buttons = WidgetAddonButtons(window)
36+
_ = WidgetAddonButtons(window)

addonmanager_devmode_people_table.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ def __init__(self):
4343
)
4444
icon_path = os.path.join(os.path.dirname(__file__), "Resources", "icons")
4545
self.widget.addButton.setIcon(
46-
QtGui.QIcon.fromTheme("add", QtGui.QIcon(os.path.join("list-add.svg")))
46+
QtGui.QIcon.fromTheme("add", QtGui.QIcon(os.path.join(icon_path, "list-add.svg")))
4747
)
4848
self.widget.removeButton.setIcon(
49-
QtGui.QIcon.fromTheme("remove", QtGui.QIcon(os.path.join("list-remove.svg")))
49+
QtGui.QIcon.fromTheme("remove", QtGui.QIcon(os.path.join(icon_path, "list-remove.svg")))
5050
)
5151

5252
self.widget.addButton.clicked.connect(self._add_clicked)

addonmanager_installer_gui.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ def _ask_for_toolbar(self, custom_toolbars):
634634
toolbar = self.toolbar_adapter.get_toolbar_with_name(custom_toolbar_name)
635635
if not toolbar:
636636
# They told us not to ask, but then the toolbar got deleted... ask anyway!
637-
ask = fci.Preferences().rem("alwaysAskForToolbar")
637+
fci.Preferences().rem("alwaysAskForToolbar")
638638
return self._ask_for_toolbar(custom_toolbars)
639639
return toolbar
640640

0 commit comments

Comments
 (0)