From 09ba0057e3d7f8c9d1166269b232a8b2692fa506 Mon Sep 17 00:00:00 2001 From: Rakielle Date: Sat, 15 Oct 2022 20:19:33 +0100 Subject: [PATCH] tdf#132293 remove unused imports and variables I used pyflakes to check for any unused imports and variables in python scripts under sc, sw, uitest directories, and then removed the unused imports and variables Change-Id: I0690c9366087dc602ee8ea169bc1c9063033fef6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141421 Tested-by: Jenkins Reviewed-by: Ilmari Lauhakangas Reviewed-by: Xisco Fauli --- sc/qa/uitest/autofilter/autofilterBugs.py | 4 ++-- sc/qa/uitest/calc_tests/goToSheet.py | 2 +- sc/qa/uitest/calc_tests7/tdf150044.py | 2 -- sc/qa/uitest/calc_tests9/tdf149529.py | 1 - sc/qa/uitest/chart/tdf93506_trendline.py | 2 +- sc/qa/uitest/chart/tdf98690.py | 2 +- sc/qa/uitest/pasteSpecial/tdf118308.py | 1 - sc/qa/uitest/range_name/tdf150307.py | 1 - sw/qa/python/check_styles.py | 10 +++++----- sw/qa/python/text_portion_enumeration_test.py | 2 +- sw/qa/uitest/chart/tdf149718.py | 6 ++---- sw/qa/uitest/writer_tests2/bookmark.py | 2 +- sw/qa/uitest/writer_tests2/deleteFootnotes.py | 2 -- sw/qa/uitest/writer_tests7/tdf150443.py | 2 +- uitest/demo_ui/checkbox.py | 2 -- uitest/demo_ui/combobox.py | 2 -- uitest/demo_ui/edit.py | 2 -- uitest/demo_ui/handle_multiple_files.py | 6 ++---- uitest/demo_ui/hierarchy.py | 2 -- uitest/demo_ui/listbox.py | 3 --- uitest/demo_ui/radiobutton.py | 14 -------------- uitest/demo_ui/spinfield.py | 4 +--- uitest/demo_ui/tabdialog.py | 3 --- uitest/demo_ui/treelist.py | 2 +- uitest/libreoffice/connection.py | 1 - uitest/libreoffice/uno/eventlistener.py | 1 - uitest/libreoffice/uno/propertyvalue.py | 1 - uitest/math_tests/start.py | 4 ---- 28 files changed, 19 insertions(+), 67 deletions(-) diff --git a/sc/qa/uitest/autofilter/autofilterBugs.py b/sc/qa/uitest/autofilter/autofilterBugs.py index a295c6307793..100ceaf246f1 100644 --- a/sc/qa/uitest/autofilter/autofilterBugs.py +++ b/sc/qa/uitest/autofilter/autofilterBugs.py @@ -26,7 +26,7 @@ class autofilter(UITestCase): self.assertEqual(calc_doc.getPropertyValue("UnnamedDatabaseRanges").getByTable(0).AutoFilter, True) def test_tdf123095(self): - with self.ui_test.create_doc_in_start_center("calc") as document: + with self.ui_test.create_doc_in_start_center("calc"): calcDoc = self.xUITest.getTopFocusWindow() xGridWindow = calcDoc.getChild("grid_window") enter_text_to_cell(xGridWindow, "A1", "乙二醇(进口料件)") @@ -46,7 +46,7 @@ class autofilter(UITestCase): self.assertEqual(get_state_as_dict(xTreeList.getChild("1"))["Text"], "乙二醇(进口料件)") def test_tdf125363(self): - with self.ui_test.create_doc_in_start_center("calc") as document: + with self.ui_test.create_doc_in_start_center("calc"): calcDoc = self.xUITest.getTopFocusWindow() xGridWindow = calcDoc.getChild("grid_window") enter_text_to_cell(xGridWindow, "A1", "guet") diff --git a/sc/qa/uitest/calc_tests/goToSheet.py b/sc/qa/uitest/calc_tests/goToSheet.py index ab2311374b71..f77fb24e8856 100644 --- a/sc/qa/uitest/calc_tests/goToSheet.py +++ b/sc/qa/uitest/calc_tests/goToSheet.py @@ -12,7 +12,7 @@ from libreoffice.uno.propertyvalue import mkPropertyValues class goToSheet(UITestCase): def test_go_to_sheet(self): - with self.ui_test.create_doc_in_start_center("calc") as document: + with self.ui_test.create_doc_in_start_center("calc"): xCalcDoc = self.xUITest.getTopFocusWindow() xGridWindow = xCalcDoc.getChild("grid_window") diff --git a/sc/qa/uitest/calc_tests7/tdf150044.py b/sc/qa/uitest/calc_tests7/tdf150044.py index 6e42358d7b81..6f70eccc7921 100644 --- a/sc/qa/uitest/calc_tests7/tdf150044.py +++ b/sc/qa/uitest/calc_tests7/tdf150044.py @@ -8,8 +8,6 @@ # from uitest.framework import UITestCase from libreoffice.uno.propertyvalue import mkPropertyValues -from org.libreoffice.unotest import systemPathToFileUrl -from uitest.uihelper.common import select_by_text from tempfile import TemporaryDirectory import os.path diff --git a/sc/qa/uitest/calc_tests9/tdf149529.py b/sc/qa/uitest/calc_tests9/tdf149529.py index 59f6826e3332..afd355da5f82 100644 --- a/sc/qa/uitest/calc_tests9/tdf149529.py +++ b/sc/qa/uitest/calc_tests9/tdf149529.py @@ -9,7 +9,6 @@ from uitest.framework import UITestCase from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file -from uitest.uihelper.common import select_by_text from libreoffice.uno.propertyvalue import mkPropertyValues from libreoffice.calc.document import get_cell_by_position diff --git a/sc/qa/uitest/chart/tdf93506_trendline.py b/sc/qa/uitest/chart/tdf93506_trendline.py index 2c4ba720601c..a70a75a922b8 100644 --- a/sc/qa/uitest/chart/tdf93506_trendline.py +++ b/sc/qa/uitest/chart/tdf93506_trendline.py @@ -17,7 +17,7 @@ from libreoffice.uno.propertyvalue import mkPropertyValues # test all dialog items - trend Line dialog class tdf93506(UITestCase): def test_tdf93506_chart_trendline_dialog(self): - with self.ui_test.load_file(get_url_for_data_file("tdf93506.ods")) as calc_doc: + with self.ui_test.load_file(get_url_for_data_file("tdf93506.ods")): xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") diff --git a/sc/qa/uitest/chart/tdf98690.py b/sc/qa/uitest/chart/tdf98690.py index f772c4e6d12a..8cd6b82c0359 100644 --- a/sc/qa/uitest/chart/tdf98690.py +++ b/sc/qa/uitest/chart/tdf98690.py @@ -13,7 +13,7 @@ from uitest.uihelper.common import get_url_for_data_file class tdf98690(UITestCase): def test_tdf98690(self): - with self.ui_test.load_file(get_url_for_data_file("tdf98690.xlsx")) as calc_doc: + with self.ui_test.load_file(get_url_for_data_file("tdf98690.xlsx")): xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") diff --git a/sc/qa/uitest/pasteSpecial/tdf118308.py b/sc/qa/uitest/pasteSpecial/tdf118308.py index 0c0f3689b742..68c462414b01 100644 --- a/sc/qa/uitest/pasteSpecial/tdf118308.py +++ b/sc/qa/uitest/pasteSpecial/tdf118308.py @@ -7,7 +7,6 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. # from uitest.framework import UITestCase -from uitest.uihelper.common import get_state_as_dict from libreoffice.uno.propertyvalue import mkPropertyValues from uitest.uihelper.calc import enter_text_to_cell from libreoffice.calc.document import get_cell_by_position diff --git a/sc/qa/uitest/range_name/tdf150307.py b/sc/qa/uitest/range_name/tdf150307.py index 30d0e15a60e7..056445408fce 100644 --- a/sc/qa/uitest/range_name/tdf150307.py +++ b/sc/qa/uitest/range_name/tdf150307.py @@ -44,7 +44,6 @@ class tdf150307(UITestCase): with self.ui_test.create_doc_in_start_center("calc"): xCalcDoc = self.xUITest.getTopFocusWindow() xGridWin = xCalcDoc.getChild("grid_window") - xPosWindow = xCalcDoc.getChild('pos_window') self.xUITest.executeCommand(".uno:Sidebar") diff --git a/sw/qa/python/check_styles.py b/sw/qa/python/check_styles.py index d19f9850b445..113fd801593c 100644 --- a/sw/qa/python/check_styles.py +++ b/sw/qa/python/check_styles.py @@ -103,21 +103,21 @@ class CheckStyle(unittest.TestCase): xFamily.removeByName(xRightStyle2.Name) with self.assertRaises(NoSuchElementException): - nope = xFamily.getByName("RightStyleOld") + xFamily.getByName("RightStyleOld") with self.assertRaises(NoSuchElementException): - nope = xFamily.getByName("RightStyle") + xFamily.getByName("RightStyle") with self.assertRaises(NoSuchElementException): - nope = xFamily.getByName("RightStyle2Old") + xFamily.getByName("RightStyle2Old") with self.assertRaises(NoSuchElementException): - nope = xFamily.getByName("RightStyle2") + xFamily.getByName("RightStyle2") with self.assertRaises(IllegalArgumentException): xFamily.insertByName("WrongStyle", xWrongStyle) with self.assertRaises(NoSuchElementException): - nope = xFamily.getByName("WrongStyle") + xFamily.getByName("WrongStyle") def test_CharacterFamily(self): xDoc = CheckStyle._uno.openEmptyWriterDoc() diff --git a/sw/qa/python/text_portion_enumeration_test.py b/sw/qa/python/text_portion_enumeration_test.py index 3de536dc7c8f..c183aaf41b09 100644 --- a/sw/qa/python/text_portion_enumeration_test.py +++ b/sw/qa/python/text_portion_enumeration_test.py @@ -3271,7 +3271,7 @@ class TextPortionEnumerationTest(unittest.TestCase): try: if i_comp: i_comp.close(True) - except Exception as e: + except Exception: pass def test_load_store(self): diff --git a/sw/qa/uitest/chart/tdf149718.py b/sw/qa/uitest/chart/tdf149718.py index 873379a36909..9486355c4113 100644 --- a/sw/qa/uitest/chart/tdf149718.py +++ b/sw/qa/uitest/chart/tdf149718.py @@ -9,13 +9,11 @@ from uitest.framework import UITestCase from libreoffice.uno.propertyvalue import mkPropertyValues -from uitest.uihelper.common import get_state_as_dict -from uitest.uihelper.common import select_pos class tdf149718( UITestCase ): def test_chart_from_table_with_merged_cells( self ): - with self.ui_test.create_doc_in_start_center("writer") as document: + with self.ui_test.create_doc_in_start_center("writer"): xWriterDoc = self.xUITest.getTopFocusWindow() xWriterEdit = xWriterDoc.getChild("writer_edit") with self.ui_test.execute_dialog_through_command(".uno:InsertTable") as xDialog: @@ -35,6 +33,6 @@ class tdf149718( UITestCase ): xWriterEdit.executeAction("TYPE", mkPropertyValues({"TEXT": "1"})) self.xUITest.executeCommand(".uno:CharRightSel") with self.ui_test.execute_dialog_through_command(".uno:InsertObjectChart", close_button="finish") as xDialog: - xWizard = xDialog.getChild('Wizard') + xDialog.getChild('Wizard') # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests2/bookmark.py b/sw/qa/uitest/writer_tests2/bookmark.py index f9d75434ffcf..87f19ceea353 100644 --- a/sw/qa/uitest/writer_tests2/bookmark.py +++ b/sw/qa/uitest/writer_tests2/bookmark.py @@ -122,7 +122,7 @@ class bookmarkDialog(UITestCase): self.assertEqual(get_state_as_dict(x1stListEntry)["Text"], "1\tBookmark 1\tfubar\tNo\t") def test_bookmark_dialog_hidden_from_DOCX_import(self): - with self.ui_test.load_file(get_url_for_data_file("tdf95495.docx")) as XDoc: + with self.ui_test.load_file(get_url_for_data_file("tdf95495.docx")): # check Hidden field of the imported hidden bookmarks with self.ui_test.execute_dialog_through_command(".uno:InsertBookmark", close_button="close") as xBookDlg: diff --git a/sw/qa/uitest/writer_tests2/deleteFootnotes.py b/sw/qa/uitest/writer_tests2/deleteFootnotes.py index 162cc7d3e1b2..0c6644097a51 100644 --- a/sw/qa/uitest/writer_tests2/deleteFootnotes.py +++ b/sw/qa/uitest/writer_tests2/deleteFootnotes.py @@ -10,8 +10,6 @@ from uitest.framework import UITestCase from uitest.uihelper.common import type_text from libreoffice.uno.propertyvalue import mkPropertyValues -import time - class tdf150457(UITestCase): diff --git a/sw/qa/uitest/writer_tests7/tdf150443.py b/sw/qa/uitest/writer_tests7/tdf150443.py index 8cca7c78e6c8..fb39bd8a0375 100644 --- a/sw/qa/uitest/writer_tests7/tdf150443.py +++ b/sw/qa/uitest/writer_tests7/tdf150443.py @@ -14,7 +14,7 @@ from libreoffice.uno.propertyvalue import mkPropertyValues class tdf150443(UITestCase): def test_tdf150443(self): - with self.ui_test.load_file(get_url_for_data_file("tdf150443.docx")) as document: + with self.ui_test.load_file(get_url_for_data_file("tdf150443.docx")): xWriterDoc = self.xUITest.getTopFocusWindow() xWriterEdit = xWriterDoc.getChild("writer_edit") xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit') diff --git a/uitest/demo_ui/checkbox.py b/uitest/demo_ui/checkbox.py index bb0f1f60a630..7c83d71f0ad8 100644 --- a/uitest/demo_ui/checkbox.py +++ b/uitest/demo_ui/checkbox.py @@ -7,8 +7,6 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. # -from libreoffice.uno.propertyvalue import mkPropertyValues - from uitest.framework import UITestCase class CheckBoxTest(UITestCase): diff --git a/uitest/demo_ui/combobox.py b/uitest/demo_ui/combobox.py index 56d4a4e79ae7..1ec4b30d6f1e 100644 --- a/uitest/demo_ui/combobox.py +++ b/uitest/demo_ui/combobox.py @@ -7,8 +7,6 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. # -from libreoffice.uno.propertyvalue import mkPropertyValues - from uitest.framework import UITestCase from uitest.uihelper.common import select_pos diff --git a/uitest/demo_ui/edit.py b/uitest/demo_ui/edit.py index 59516b13a701..7a0fbb2b8a7e 100644 --- a/uitest/demo_ui/edit.py +++ b/uitest/demo_ui/edit.py @@ -12,8 +12,6 @@ from libreoffice.uno.propertyvalue import mkPropertyValues from uitest.framework import UITestCase from uitest.uihelper.common import type_text, get_state_as_dict, select_text -import time - class EditTest(UITestCase): def test_type_text(self): diff --git a/uitest/demo_ui/handle_multiple_files.py b/uitest/demo_ui/handle_multiple_files.py index 406bb2b519eb..a15b92deeccb 100644 --- a/uitest/demo_ui/handle_multiple_files.py +++ b/uitest/demo_ui/handle_multiple_files.py @@ -7,8 +7,6 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. # -from libreoffice.uno.propertyvalue import mkPropertyValues -from libreoffice.uno.eventlistener import EventListener from uitest.framework import UITestCase from uitest.uihelper.common import get_url_for_data_file import time @@ -17,7 +15,7 @@ class HandleFiles(UITestCase): def test_load_file(self): - with self.ui_test.load_file(get_url_for_data_file("test.ods")) as calc_file: + with self.ui_test.load_file(get_url_for_data_file("test.ods")): with self.ui_test.load_file(get_url_for_data_file("test2.ods")): @@ -34,7 +32,7 @@ class HandleFiles(UITestCase): time.sleep(1) def test_select_frame(self): - with self.ui_test.load_file(get_url_for_data_file("test.ods")) as calc_file: + with self.ui_test.load_file(get_url_for_data_file("test.ods")): with self.ui_test.load_file(get_url_for_data_file("test2.ods")): frames = self.ui_test.get_frames() diff --git a/uitest/demo_ui/hierarchy.py b/uitest/demo_ui/hierarchy.py index 19cb4c34b54d..a447de563e4a 100644 --- a/uitest/demo_ui/hierarchy.py +++ b/uitest/demo_ui/hierarchy.py @@ -7,8 +7,6 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. # -from libreoffice.uno.propertyvalue import mkPropertyValues - from uitest.framework import UITestCase import json diff --git a/uitest/demo_ui/listbox.py b/uitest/demo_ui/listbox.py index 9e762c5218d2..b59a7b0a0a8f 100644 --- a/uitest/demo_ui/listbox.py +++ b/uitest/demo_ui/listbox.py @@ -7,10 +7,7 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. # -from libreoffice.uno.propertyvalue import mkPropertyValues - from uitest.framework import UITestCase -from uitest.uihelper.common import select_pos class ListBoxTest(UITestCase): diff --git a/uitest/demo_ui/radiobutton.py b/uitest/demo_ui/radiobutton.py index cc5a3b67bf97..268696e56e66 100644 --- a/uitest/demo_ui/radiobutton.py +++ b/uitest/demo_ui/radiobutton.py @@ -7,22 +7,8 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. # -from libreoffice.uno.propertyvalue import mkPropertyValues - from uitest.framework import UITestCase -import time - -try: - import pyuno - import uno - import unohelper -except ImportError: - print("pyuno not found: try to set PYTHONPATH and URE_BOOTSTRAP variables") - print("PYTHONPATH=/installation/opt/program") - print("URE_BOOTSTRAP=file:///installation/opt/program/fundamentalrc") - raise - class RadioButtonTest(UITestCase): def test_toggle_radiobutton(self): diff --git a/uitest/demo_ui/spinfield.py b/uitest/demo_ui/spinfield.py index 5511fec0827e..6b6a3bce0f22 100644 --- a/uitest/demo_ui/spinfield.py +++ b/uitest/demo_ui/spinfield.py @@ -7,10 +7,8 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. # -from libreoffice.uno.propertyvalue import mkPropertyValues - from uitest.framework import UITestCase -from uitest.uihelper.common import get_state_as_dict, type_text, select_pos +from uitest.uihelper.common import get_state_as_dict, type_text class SpinFieldTest(UITestCase): diff --git a/uitest/demo_ui/tabdialog.py b/uitest/demo_ui/tabdialog.py index 73167ea6524d..6ed5bcc06983 100644 --- a/uitest/demo_ui/tabdialog.py +++ b/uitest/demo_ui/tabdialog.py @@ -7,10 +7,7 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. # -from libreoffice.uno.propertyvalue import mkPropertyValues - from uitest.framework import UITestCase -from uitest.uihelper.common import select_pos class TabDialogTest(UITestCase): diff --git a/uitest/demo_ui/treelist.py b/uitest/demo_ui/treelist.py index e80176c52b88..214fc4b08e70 100644 --- a/uitest/demo_ui/treelist.py +++ b/uitest/demo_ui/treelist.py @@ -10,7 +10,7 @@ from libreoffice.uno.propertyvalue import mkPropertyValues from uitest.uihelper.calc import enter_text_to_cell -from uitest.uihelper.common import get_state_as_dict, select_pos +from uitest.uihelper.common import select_pos from uitest.framework import UITestCase diff --git a/uitest/libreoffice/connection.py b/uitest/libreoffice/connection.py index 2b0e9c227479..40c4757406ab 100644 --- a/uitest/libreoffice/connection.py +++ b/uitest/libreoffice/connection.py @@ -14,7 +14,6 @@ import os try: import pyuno import uno - import unohelper except ImportError: print("pyuno not found: try to set PYTHONPATH and URE_BOOTSTRAP variables") print("PYTHONPATH=/installation/opt/program") diff --git a/uitest/libreoffice/uno/eventlistener.py b/uitest/libreoffice/uno/eventlistener.py index b2b834b13d03..54076efe337e 100644 --- a/uitest/libreoffice/uno/eventlistener.py +++ b/uitest/libreoffice/uno/eventlistener.py @@ -6,7 +6,6 @@ # try: - import pyuno import unohelper from com.sun.star.document import XDocumentEventListener except ImportError: diff --git a/uitest/libreoffice/uno/propertyvalue.py b/uitest/libreoffice/uno/propertyvalue.py index 4e5c8964bc60..ce8622113a9a 100644 --- a/uitest/libreoffice/uno/propertyvalue.py +++ b/uitest/libreoffice/uno/propertyvalue.py @@ -6,7 +6,6 @@ # try: - import pyuno import uno except ImportError: print("pyuno not found: try to set PYTHONPATH and URE_BOOTSTRAP variables") diff --git a/uitest/math_tests/start.py b/uitest/math_tests/start.py index 962d74e686f4..6b3278acf907 100644 --- a/uitest/math_tests/start.py +++ b/uitest/math_tests/start.py @@ -14,9 +14,6 @@ from libreoffice.uno.propertyvalue import mkPropertyValues from uitest.framework import UITestCase from uitest.uihelper.common import type_text, select_pos -import unittest -import platform - class SimpleMathTest(UITestCase): def test_math_unoCommand(self): @@ -39,7 +36,6 @@ class SimpleMathTest(UITestCase): xEditView = xMathDoc.getChild("editview") type_text(xEditView, "E=mc^2") - xMathEdit = xMathDoc.getChild("editview") self.assertEqual("E=mc^2", get_state_as_dict(xEditView)["Text"])