Replace more pylint sections with ruff

This commit is contained in:
2Shirt 2023-03-27 00:09:08 -07:00
parent aea1373df7
commit 9dc900c75e
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C
8 changed files with 26 additions and 39 deletions

View file

@ -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)
wk.kit.tools.run_tool('RUST', 'RUST', popen=True)

View file

@ -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"]

View file

@ -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':

View file

@ -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:

View file

@ -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 = []

View file

@ -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 = []

View file

@ -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

View file

@ -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