From 9dc900c75eab2828755093ba76b31295661b979b Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Mon, 27 Mar 2023 00:09:08 -0700 Subject: [PATCH] Replace more pylint sections with ruff --- scripts/launch_stress_tests.py | 9 ++------ scripts/pyproject.toml | 6 ++++- scripts/wk/hw/benchmark.py | 3 +-- scripts/wk/hw/diags.py | 40 ++++++++++++++-------------------- scripts/wk/hw/osticket.py | 2 -- scripts/wk/os/mac.py | 1 - scripts/wk/osticket.py | 2 +- scripts/wk/repairs/win.py | 2 +- 8 files changed, 26 insertions(+), 39 deletions(-) diff --git a/scripts/launch_stress_tests.py b/scripts/launch_stress_tests.py index 6b68b51b..e3e0d4ad 100755 --- a/scripts/launch_stress_tests.py +++ b/scripts/launch_stress_tests.py @@ -1,14 +1,9 @@ """WizardKit: Launch Stress Tests Tool""" # vim: sts=2 sw=2 ts=2 -import os -import sys - -os.chdir(os.path.dirname(os.path.realpath(__file__))) -sys.path.append(os.getcwd()) -import wk # pylint: disable=wrong-import-position +import wk wk.kit.tools.run_tool('CoreTemp', 'CoreTemp', popen=True) wk.kit.tools.run_tool('FurMark', 'FurMark', popen=True) wk.kit.tools.run_tool('Prime95', 'prime95', popen=True) -wk.kit.tools.run_tool('RUST', 'RUST', popen=True) \ No newline at end of file +wk.kit.tools.run_tool('RUST', 'RUST', popen=True) diff --git a/scripts/pyproject.toml b/scripts/pyproject.toml index 05f92df9..8ad87a8d 100644 --- a/scripts/pyproject.toml +++ b/scripts/pyproject.toml @@ -10,9 +10,13 @@ "wk/setup/__init__.py" = ["F401"] # Long lines -"wk/borrowed/acpi.py" = ["E501", "F841"] +"auto_setup.py" = ["E501"] "wk/cfg/ddrescue.py" = ["E501"] "wk/cfg/hw.py" = ["E501"] "wk/cfg/launchers.py" = ["E501"] "wk/cfg/setup.py" = ["E501"] "wk/cfg/sources.py" = ["E501"] + +# Misc +"set_lp8550_slope.py" = ["E501", "E741"] +"wk/borrowed/acpi.py" = ["E501", "F841"] diff --git a/scripts/wk/hw/benchmark.py b/scripts/wk/hw/benchmark.py index 31210506..31e5126b 100644 --- a/scripts/wk/hw/benchmark.py +++ b/scripts/wk/hw/benchmark.py @@ -168,14 +168,13 @@ def export_and_upload_graphs(state, test_obj, rate_list): image_path, state.ost.ticket_id, test_obj.dev.path.name) test_obj.report.append(f'Imgur: {imgur_url}') test_obj.report.append(f'Nextcloud: {nextcloud_url}') - except Exception as err: # pylint: disable=broad-except + except Exception as err: LOG.error('%s', err) LOG.error('Failed to upload graph') test_obj.report.append('Failed to upload graph') def run_io_test(state, test_obj, log_path, test_mode=False) -> None: - #pylint: disable=too-many-locals """Run I/O benchmark and handle exceptions.""" dev_path = test_obj.dev.path if PLATFORM == 'Darwin': diff --git a/scripts/wk/hw/diags.py b/scripts/wk/hw/diags.py index 82d62716..191f3aa5 100644 --- a/scripts/wk/hw/diags.py +++ b/scripts/wk/hw/diags.py @@ -1,5 +1,4 @@ """WizardKit: Hardware diagnostics""" -# pylint: disable=too-many-lines # vim: sts=2 sw=2 ts=2 import atexit @@ -97,7 +96,6 @@ PLATFORM = std.PLATFORM # Classes class State(): - # pylint: disable=too-many-instance-attributes """Object for tracking hardware diagnostic data.""" def __init__(self, test_mode=False): self.cpu_max_temp = -1 @@ -812,7 +810,6 @@ def disk_surface_scan(state, test_objects, test_mode=False) -> None: def disk_volume_utilization(state, test_objects, test_mode=False) -> None: - # pylint: disable=unused-argument """Check disk for full volumes.""" LOG.info('Disk Utilization') for test in test_objects: @@ -836,7 +833,7 @@ def main() -> None: atexit.register(tmux.kill_all_panes) menu = build_menu(cli_mode=args['--cli'], quick_mode=args['--quick']) state = State(test_mode=args['--test-mode']) - state.override_all_smart_errors = args['--ignore-smart-errors'] # pylint: disable=attribute-defined-outside-init + state.override_all_smart_errors = args['--ignore-smart-errors'] # Quick Mode if args['--quick']: @@ -897,7 +894,6 @@ def main() -> None: def post_system_info(state, quick_mode=False, test_mode=False) -> None: - # pylint: disable=unused-argument """Post system info to osTicket.""" # Bail early if state.ost.disabled: @@ -948,24 +944,6 @@ def run_diags(state, menu, quick_mode=False, test_mode=False) -> None: atexit.register(state.save_debug_reports) state.init_diags(menu) - def _init_osticket(): - """Dumb private function to avoid pylint error.""" - if not state.ost.disabled: - # Select Ticket - state.ost.select_ticket() - - # Update top_text - if state.ost.ticket_id: - state.top_text += std.color_string( - [f' #{state.ost.ticket_id}', state.ost.ticket_name], - [None, 'CYAN'], - ) - - # Add note - if (state.ost.ticket_id - and menu.toggles['osTicket Tech Note']['Selected']): - state.ost.add_note() - # Just return if no tests were selected if not state.test_groups: std.print_warning('No tests selected?') @@ -973,7 +951,21 @@ def run_diags(state, menu, quick_mode=False, test_mode=False) -> None: return # osTicket - _init_osticket() + if not state.ost.disabled: + # Select Ticket + state.ost.select_ticket() + + # Update top_text + if state.ost.ticket_id: + state.top_text += std.color_string( + [f' #{state.ost.ticket_id}', state.ost.ticket_name], + [None, 'CYAN'], + ) + + # Add note + if (state.ost.ticket_id + and menu.toggles['osTicket Tech Note']['Selected']): + state.ost.add_note() # Run tests for group in state.test_groups: diff --git a/scripts/wk/hw/osticket.py b/scripts/wk/hw/osticket.py index bca1d2ad..88648bd8 100644 --- a/scripts/wk/hw/osticket.py +++ b/scripts/wk/hw/osticket.py @@ -18,7 +18,6 @@ LOG = logging.getLogger(__name__) # Functions def build_report(dev, dev_type, num_disk_tests=None): - # pylint: disable=too-many-branches """Build report for posting to osTicket, returns str.""" report = [] @@ -162,7 +161,6 @@ def post_disk_results(state, num_disk_tests): def update_checkboxes(state, num_disk_tests): - # pylint: disable=too-many-branches """Update osTicket checkboxes after confirmation.""" cpu_tests = [] disk_tests = [] diff --git a/scripts/wk/os/mac.py b/scripts/wk/os/mac.py index e6a84d35..1a461557 100644 --- a/scripts/wk/os/mac.py +++ b/scripts/wk/os/mac.py @@ -65,7 +65,6 @@ def get_apfs_volumes(device_path): def get_core_storage_volumes(device_path): - # pylint: disable=too-many-branches """Get CoreStorage volumes contained in device_path, returns list.""" disks = [] volumes = [] diff --git a/scripts/wk/osticket.py b/scripts/wk/osticket.py index da542140..910b69e9 100644 --- a/scripts/wk/osticket.py +++ b/scripts/wk/osticket.py @@ -33,7 +33,7 @@ TABLE_TICKET = 'ost_ticket' # Classes -class osTicket(): # pylint: disable=invalid-name +class osTicket(): """Class to track osTicket data and functions.""" def __init__(self): self.db_connection = None diff --git a/scripts/wk/repairs/win.py b/scripts/wk/repairs/win.py index c26ddf1a..5e3d64cf 100644 --- a/scripts/wk/repairs/win.py +++ b/scripts/wk/repairs/win.py @@ -1573,7 +1573,7 @@ def open_defender_settings(disable=False, enable=False): proc = run_program(cmd) status = proc.stdout.split('=')[1] enabled = bool(int(status) & MS_ANTIVIRUS_ENABLED) - except Exception: # pylint: disable=broad-except + except Exception: # Unknown result, just show the prompt pass