From 5373679b695e5bd4f68fe4554234dd9facc3e54f Mon Sep 17 00:00:00 2001 From: Ilmari Lauhakangas Date: Sat, 27 Jul 2024 21:10:58 +0300 Subject: [PATCH] sc: fix issues found by Ruff linter Change-Id: I6710db13549c42e9ae7231e0434a26b6357083e1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171102 Tested-by: Ilmari Lauhakangas Reviewed-by: Ilmari Lauhakangas --- sc/qa/uitest/autofilter2/tdf158440.py | 3 +-- sc/qa/uitest/autofilter2/tdf161457.py | 2 +- sc/qa/uitest/calc_tests9/tdf115474.py | 3 --- sc/qa/uitest/calc_tests9/tdf159707.py | 3 --- sc/qa/uitest/chart/chartDataLabels.py | 4 ++-- sc/qa/uitest/pasteSpecial/tdf158110.py | 2 +- sc/workben/celltrans/parse.py | 4 ++-- 7 files changed, 7 insertions(+), 14 deletions(-) diff --git a/sc/qa/uitest/autofilter2/tdf158440.py b/sc/qa/uitest/autofilter2/tdf158440.py index df0b17c6706e..28b88cc1199e 100644 --- a/sc/qa/uitest/autofilter2/tdf158440.py +++ b/sc/qa/uitest/autofilter2/tdf158440.py @@ -9,13 +9,12 @@ from uitest.framework import UITestCase from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file from libreoffice.uno.propertyvalue import mkPropertyValues -from libreoffice.calc.document import get_cell_by_position class tdf158440(UITestCase): def test_tdf158440(self): - with self.ui_test.load_file(get_url_for_data_file("tdf158440.ods")) as calc_doc: + with self.ui_test.load_file(get_url_for_data_file("tdf158440.ods")): xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") diff --git a/sc/qa/uitest/autofilter2/tdf161457.py b/sc/qa/uitest/autofilter2/tdf161457.py index 400f4df9b584..bbe63f770a45 100644 --- a/sc/qa/uitest/autofilter2/tdf161457.py +++ b/sc/qa/uitest/autofilter2/tdf161457.py @@ -14,7 +14,7 @@ class tdf161457(UITestCase): def test_tdf161457(self): - with self.ui_test.load_file(get_url_for_data_file("tdf161457.ods")) as calc_doc: + with self.ui_test.load_file(get_url_for_data_file("tdf161457.ods")): xCalcDoc = self.xUITest.getTopFocusWindow() xGridWin = xCalcDoc.getChild("grid_window") diff --git a/sc/qa/uitest/calc_tests9/tdf115474.py b/sc/qa/uitest/calc_tests9/tdf115474.py index 92ca5cc7b7e6..f1de3b7d9d67 100644 --- a/sc/qa/uitest/calc_tests9/tdf115474.py +++ b/sc/qa/uitest/calc_tests9/tdf115474.py @@ -7,10 +7,7 @@ # 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 uitest.uihelper.common import select_by_text, select_pos from libreoffice.calc.document import get_cell_by_position - from libreoffice.uno.propertyvalue import mkPropertyValues class tdf115474(UITestCase): diff --git a/sc/qa/uitest/calc_tests9/tdf159707.py b/sc/qa/uitest/calc_tests9/tdf159707.py index 1e7b240f4b56..4d6721ed9e91 100644 --- a/sc/qa/uitest/calc_tests9/tdf159707.py +++ b/sc/qa/uitest/calc_tests9/tdf159707.py @@ -9,9 +9,6 @@ from uitest.framework import UITestCase from uitest.uihelper.common import get_url_for_data_file -from libreoffice.uno.propertyvalue import mkPropertyValues -from com.sun.star.beans import PropertyValue - class tdf159707(UITestCase): def test_tdf159707(self): diff --git a/sc/qa/uitest/chart/chartDataLabels.py b/sc/qa/uitest/chart/chartDataLabels.py index da94cde5fa87..cbdfb30e82d5 100644 --- a/sc/qa/uitest/chart/chartDataLabels.py +++ b/sc/qa/uitest/chart/chartDataLabels.py @@ -225,8 +225,8 @@ class chartDataLabels(UITestCase): sourceformat = dialog.getChild("sourceformat") # Select currency - sourceformat.executeAction("CLICK", tuple()); - categoryformat.getChild("4").executeAction("SELECT", tuple()); + sourceformat.executeAction("CLICK", tuple()) + categoryformat.getChild("4").executeAction("SELECT", tuple()) self.assertEqual(get_state_as_dict(categoryformat)["SelectEntryText"], "Currency") diff --git a/sc/qa/uitest/pasteSpecial/tdf158110.py b/sc/qa/uitest/pasteSpecial/tdf158110.py index 9d775226c030..a2a83c0f3523 100644 --- a/sc/qa/uitest/pasteSpecial/tdf158110.py +++ b/sc/qa/uitest/pasteSpecial/tdf158110.py @@ -47,7 +47,7 @@ class tdf158110(UITestCase): self.assertEqual("Comment 1", get_cell_by_position(document, 0, 1, 0).Annotation.String) def test_tdf158110_paste_special_overwrite_comments(self): - with self.ui_test.create_doc_in_start_center("calc") as document: + with self.ui_test.create_doc_in_start_center("calc"): xGridWin = self.xUITest.getTopFocusWindow().getChild("grid_window") # Insert a comments diff --git a/sc/workben/celltrans/parse.py b/sc/workben/celltrans/parse.py index 937d92f64d28..4b604cbe9ab3 100644 --- a/sc/workben/celltrans/parse.py +++ b/sc/workben/celltrans/parse.py @@ -39,7 +39,7 @@ class LocaleData(object): self.funcList = {} def addKeywordMap (self, funcName, localeName, engName): - if not funcName in self.funcList: + if funcName not in self.funcList: self.funcList[funcName] = [] self.funcList[funcName].append([localeName, engName]) @@ -118,7 +118,7 @@ class Parser(object): bl = self.bytes[self.i+1] try: dbyte = ord(bl)*256 + ord(bh) - except: + except Exception: dbyte = bl*256 + bh self.i += 2 return dbyte