From d4e037f3384765e7bb8fb020cecbf3db24fc7494 Mon Sep 17 00:00:00 2001 From: wyzula-jan Date: Fri, 6 Mar 2026 10:25:45 +0100 Subject: [PATCH] refactor(black): black 26 applied --- bec_widgets/applications/launch_window.py | 6 +-- .../navigation_centre/side_bar_components.py | 6 +-- .../device_form_dialog.py | 4 +- .../device_manager_display_widget.py | 12 ++---- bec_widgets/utils/bec_login.py | 12 ++---- bec_widgets/utils/guided_tour.py | 6 +-- bec_widgets/utils/round_frame.py | 6 +-- bec_widgets/utils/toolbars/actions.py | 6 +-- bec_widgets/utils/toolbars/splitter.py | 6 +-- bec_widgets/utils/toolbars/toolbar.py | 12 ++---- .../containers/auto_update/auto_updates.py | 16 +++---- .../widgets/containers/explorer/explorer.py | 6 +-- .../notification_banner.py | 42 +++++++------------ .../available_device_group.py | 6 +-- .../widgets/dap/lmfit_dialog/lmfit_dialog.py | 6 +-- .../jupyter_console/jupyter_console.py | 6 +-- .../widgets/editors/monaco/monaco_widget.py | 6 +-- .../ring_progress_settings_cards.py | 6 +-- .../widgets/services/bec_queue/bec_queue.py | 6 +-- .../utility/ide_explorer/ide_explorer.py | 12 ++---- tests/unit_tests/test_developer_view.py | 6 +-- tests/unit_tests/test_generate_cli_client.py | 6 +-- tests/unit_tests/test_ide_explorer.py | 12 ++---- tests/unit_tests/test_macro_tree_widget.py | 42 +++++++------------ 24 files changed, 88 insertions(+), 166 deletions(-) diff --git a/bec_widgets/applications/launch_window.py b/bec_widgets/applications/launch_window.py index 4d1ef6b8..9c92673c 100644 --- a/bec_widgets/applications/launch_window.py +++ b/bec_widgets/applications/launch_window.py @@ -147,8 +147,7 @@ class LaunchTile(RoundedFrame): # Action button self.action_button = QPushButton("Open") - self.action_button.setStyleSheet( - """ + self.action_button.setStyleSheet(""" QPushButton { background-color: #007AFF; border: none; @@ -160,8 +159,7 @@ class LaunchTile(RoundedFrame): QPushButton:hover { background-color: #005BB5; } - """ - ) + """) self.layout.addWidget(self.action_button, alignment=Qt.AlignmentFlag.AlignCenter) def _fit_label_to_width(self, label: QLabel, max_width: int, min_pt: int = 10): diff --git a/bec_widgets/applications/navigation_centre/side_bar_components.py b/bec_widgets/applications/navigation_centre/side_bar_components.py index 67bb7666..2f6505af 100644 --- a/bec_widgets/applications/navigation_centre/side_bar_components.py +++ b/bec_widgets/applications/navigation_centre/side_bar_components.py @@ -127,12 +127,10 @@ class NavigationItem(QWidget): self._icon_size_expanded = QtCore.QSize(26, 26) self.icon_btn.setIconSize(self._icon_size_collapsed) # Remove QToolButton hover/pressed background/outline - self.icon_btn.setStyleSheet( - """ + self.icon_btn.setStyleSheet(""" QToolButton:hover { background: transparent; border: none; } QToolButton:pressed { background: transparent; border: none; } - """ - ) + """) # Mini label below icon self.mini_lbl = QLabel(self._mini_text, self) diff --git a/bec_widgets/applications/views/device_manager_view/device_manager_dialogs/device_form_dialog.py b/bec_widgets/applications/views/device_manager_view/device_manager_dialogs/device_form_dialog.py index 1f4b574f..11f5f701 100644 --- a/bec_widgets/applications/views/device_manager_view/device_manager_dialogs/device_form_dialog.py +++ b/bec_widgets/applications/views/device_manager_view/device_manager_dialogs/device_form_dialog.py @@ -31,7 +31,7 @@ logger = bec_logger.logger class DeviceManagerOphydValidationDialog(QtWidgets.QDialog): """Popup dialog to test Ophyd device configurations interactively.""" - def __init__(self, parent=None, config: dict | None = None): # type:ignore + def __init__(self, parent=None, config: dict | None = None): # type: ignore super().__init__(parent) self.setWindowTitle("Device Manager Ophyd Test") self._config_status = ConfigStatus.UNKNOWN.value @@ -133,7 +133,7 @@ class DeviceFormDialog(QtWidgets.QDialog): # validated: config_status, connection_status accepted_data = QtCore.Signal(dict, int, int, str, str) - def __init__(self, parent=None, add_btn_text: str = "Add Device"): # type:ignore + def __init__(self, parent=None, add_btn_text: str = "Add Device"): # type: ignore super().__init__(parent) # Track old device name if config is edited self._old_device_name: str = "" diff --git a/bec_widgets/applications/views/device_manager_view/device_manager_display_widget.py b/bec_widgets/applications/views/device_manager_view/device_manager_display_widget.py index 45dfc5eb..d4d388a7 100644 --- a/bec_widgets/applications/views/device_manager_view/device_manager_display_widget.py +++ b/bec_widgets/applications/views/device_manager_view/device_manager_display_widget.py @@ -103,16 +103,14 @@ class CustomBusyWidget(QWidget): button_width = int(button_height * aspect_ratio) self.cancel_button.setFixedSize(button_width, button_height) color = get_accent_colors() - self.cancel_button.setStyleSheet( - f""" + self.cancel_button.setStyleSheet(f""" QPushButton {{ background-color: {color.emergency.name()}; color: white; font-weight: 600; border-radius: 6px; }} - """ - ) + """) # Layout content_layout = QVBoxLayout(self) @@ -128,12 +126,10 @@ class CustomBusyWidget(QWidget): bg_color = color._colors.get("BG", None) if bg_color is None: # Fallback if missing bg_color = QColor(50, 50, 50, 255) - self.setStyleSheet( - f""" + self.setStyleSheet(f""" background-color: {bg_color.name()}; border-radius: 12px; - """ - ) + """) def _ui_scale(self) -> int: parent = self.parent() diff --git a/bec_widgets/utils/bec_login.py b/bec_widgets/utils/bec_login.py index 6f75b51c..e9a2952b 100644 --- a/bec_widgets/utils/bec_login.py +++ b/bec_widgets/utils/bec_login.py @@ -20,15 +20,13 @@ class BECLogin(QWidget): title = QLabel("Sign in", parent=self) title.setAlignment(Qt.AlignmentFlag.AlignCenter) - title.setStyleSheet( - """ + title.setStyleSheet(""" #QLabel { font-size: 18px; font-weight: 600; } - """ - ) + """) self.username = QLineEdit(parent=self) self.username.setPlaceholderText("Username") @@ -57,13 +55,11 @@ class BECLogin(QWidget): self.username.setFocus() - self.setStyleSheet( - """ + self.setStyleSheet(""" QLineEdit { padding: 8px; } - """ - ) + """) def _clear_password(self): """Clear the password field.""" diff --git a/bec_widgets/utils/guided_tour.py b/bec_widgets/utils/guided_tour.py index f38e9903..78333f20 100644 --- a/bec_widgets/utils/guided_tour.py +++ b/bec_widgets/utils/guided_tour.py @@ -67,15 +67,13 @@ class TutorialOverlay(QWidget): box = QFrame(self) app = QApplication.instance() bg_color = app.palette().window().color() - box.setStyleSheet( - f""" + box.setStyleSheet(f""" QFrame {{ background-color: {bg_color.name()}; border-radius: 8px; padding: 8px; }} - """ - ) + """) layout = QVBoxLayout(box) # Top layout with close button (left) and step indicator (right) diff --git a/bec_widgets/utils/round_frame.py b/bec_widgets/utils/round_frame.py index f8399d1b..14722b85 100644 --- a/bec_widgets/utils/round_frame.py +++ b/bec_widgets/utils/round_frame.py @@ -69,13 +69,11 @@ class RoundedFrame(QFrame): """ Update the style of the frame based on the background color. """ - self.setStyleSheet( - f""" + self.setStyleSheet(f""" QFrame#roundedFrame {{ border-radius: {self._radius}px; }} - """ - ) + """) self.apply_plot_widget_style() def apply_plot_widget_style(self, border: str = "none"): diff --git a/bec_widgets/utils/toolbars/actions.py b/bec_widgets/utils/toolbars/actions.py index f82753ff..e1cfa70f 100644 --- a/bec_widgets/utils/toolbars/actions.py +++ b/bec_widgets/utils/toolbars/actions.py @@ -599,16 +599,14 @@ class ExpandableMenuAction(ToolBarAction): button.setIcon(QIcon(self.icon_path)) button.setText(self.tooltip) button.setPopupMode(QToolButton.ToolButtonPopupMode.InstantPopup) - button.setStyleSheet( - """ + button.setStyleSheet(""" QToolButton { font-size: 14px; } QMenu { font-size: 14px; } - """ - ) + """) menu = QMenu(button) for action_container in self.actions.values(): action: QAction = action_container.action diff --git a/bec_widgets/utils/toolbars/splitter.py b/bec_widgets/utils/toolbars/splitter.py index 91805fc1..d2071172 100644 --- a/bec_widgets/utils/toolbars/splitter.py +++ b/bec_widgets/utils/toolbars/splitter.py @@ -106,8 +106,7 @@ class ResizableSpacer(QWidget): self.setSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Fixed) - self.setStyleSheet( - """ + self.setStyleSheet(""" ResizableSpacer { background-color: transparent; margin: 0px; @@ -117,8 +116,7 @@ class ResizableSpacer(QWidget): ResizableSpacer:hover { background-color: rgba(100, 100, 200, 80); } - """ - ) + """) self.setContentsMargins(0, 0, 0, 0) diff --git a/bec_widgets/utils/toolbars/toolbar.py b/bec_widgets/utils/toolbars/toolbar.py index fc2ec7ad..4d322ba4 100644 --- a/bec_widgets/utils/toolbars/toolbar.py +++ b/bec_widgets/utils/toolbars/toolbar.py @@ -291,8 +291,7 @@ class ModularToolBar(QToolBar): menu = QMenu(self) theme = get_theme_name() if theme == "dark": - menu.setStyleSheet( - """ + menu.setStyleSheet(""" QMenu { background-color: rgba(50, 50, 50, 0.9); border: 1px solid rgba(255, 255, 255, 0.2); @@ -300,12 +299,10 @@ class ModularToolBar(QToolBar): QMenu::item:selected { background-color: rgba(0, 0, 255, 0.2); } - """ - ) + """) else: # Light theme styling - menu.setStyleSheet( - """ + menu.setStyleSheet(""" QMenu { background-color: rgba(255, 255, 255, 0.9); border: 1px solid rgba(0, 0, 0, 0.2); @@ -313,8 +310,7 @@ class ModularToolBar(QToolBar): QMenu::item:selected { background-color: rgba(0, 0, 255, 0.2); } - """ - ) + """) for ii, bundle in enumerate(self.shown_bundles): self.handle_bundle_context_menu(menu, bundle) if ii < len(self.shown_bundles) - 1: diff --git a/bec_widgets/widgets/containers/auto_update/auto_updates.py b/bec_widgets/widgets/containers/auto_update/auto_updates.py index c259bda1..95424c16 100644 --- a/bec_widgets/widgets/containers/auto_update/auto_updates.py +++ b/bec_widgets/widgets/containers/auto_update/auto_updates.py @@ -46,7 +46,7 @@ class AutoUpdates(BECMainWindow): self.setCentralWidget(self.dock_area) self._auto_update_selected_device: str | None = None - self._default_dock = None # type:ignore + self._default_dock = None # type: ignore self.current_widget: BECWidget | None = None self.dock_name = None self._enabled = True @@ -63,7 +63,7 @@ class AutoUpdates(BECMainWindow): Disconnect all connections for the auto updates. """ self.bec_dispatcher.disconnect_slot( - self._on_scan_status, MessageEndpoints.scan_status() # type:ignore + self._on_scan_status, MessageEndpoints.scan_status() # type: ignore ) @property @@ -244,10 +244,10 @@ class AutoUpdates(BECMainWindow): wf = self.set_dock_to_widget("Waveform") # Get the scan report devices reported by the scan - dev_x = info.scan_report_devices[0] # type:ignore + dev_x = info.scan_report_devices[0] # type: ignore # For the y axis, get the selected device - dev_y = self.get_selected_device(info.readout_priority["monitored"]) # type:ignore + dev_y = self.get_selected_device(info.readout_priority["monitored"]) # type: ignore if not dev_y: return @@ -279,8 +279,8 @@ class AutoUpdates(BECMainWindow): scatter = self.set_dock_to_widget("ScatterWaveform") # Get the scan report devices reported by the scan - dev_x, dev_y = info.scan_report_devices[0], info.scan_report_devices[1] # type:ignore - dev_z = self.get_selected_device(info.readout_priority["monitored"]) # type:ignore + dev_x, dev_y = info.scan_report_devices[0], info.scan_report_devices[1] # type: ignore + dev_z = self.get_selected_device(info.readout_priority["monitored"]) # type: ignore if None in (dev_x, dev_y, dev_z): return @@ -309,8 +309,8 @@ class AutoUpdates(BECMainWindow): # If the scan report devices are empty, there is nothing we can do if not info.scan_report_devices: return - dev_x = info.scan_report_devices[0] # type:ignore - dev_y = self.get_selected_device(info.readout_priority["monitored"]) # type:ignore + dev_x = info.scan_report_devices[0] # type: ignore + dev_y = self.get_selected_device(info.readout_priority["monitored"]) # type: ignore if not dev_y: return diff --git a/bec_widgets/widgets/containers/explorer/explorer.py b/bec_widgets/widgets/containers/explorer/explorer.py index 25bff357..997648ef 100644 --- a/bec_widgets/widgets/containers/explorer/explorer.py +++ b/bec_widgets/widgets/containers/explorer/explorer.py @@ -101,14 +101,12 @@ class Explorer(BECWidget, QWidget): palette = get_theme_palette() separator_color = palette.mid().color() - self.splitter.setStyleSheet( - f""" + self.splitter.setStyleSheet(f""" QSplitter::handle {{ height: 0.1px; background-color: rgba({separator_color.red()}, {separator_color.green()}, {separator_color.blue()}, 60); }} - """ - ) + """) def _update_spacer(self) -> None: """Update the spacer size based on section states""" diff --git a/bec_widgets/widgets/containers/main_window/addons/notification_center/notification_banner.py b/bec_widgets/widgets/containers/main_window/addons/notification_center/notification_banner.py index a11d8465..4b99a48f 100644 --- a/bec_widgets/widgets/containers/main_window/addons/notification_center/notification_banner.py +++ b/bec_widgets/widgets/containers/main_window/addons/notification_center/notification_banner.py @@ -134,15 +134,13 @@ class NotificationToast(QFrame): bg.setAlphaF(0.30) icon_bg = bg.name(QtGui.QColor.HexArgb) icon_btn.setFixedSize(40, 40) - icon_btn.setStyleSheet( - f""" + icon_btn.setStyleSheet(f""" QToolButton {{ background: {icon_bg}; border: none; border-radius: 20px; /* perfect circle */ }} - """ - ) + """) title_lbl = QtWidgets.QLabel(self._title) @@ -327,15 +325,13 @@ class NotificationToast(QFrame): bg = QtGui.QColor(SEVERITY[value.value]["color"]) bg.setAlphaF(0.30) icon_bg = bg.name(QtGui.QColor.HexArgb) - self._icon_btn.setStyleSheet( - f""" + self._icon_btn.setStyleSheet(f""" QToolButton {{ background: {icon_bg}; border: none; border-radius: 20px; }} - """ - ) + """) self.apply_theme(self._theme) # keep injected gradient in sync if getattr(self, "_hg_enabled", False): @@ -391,8 +387,7 @@ class NotificationToast(QFrame): card_bg.setAlphaF(0.88) btn_hover = self._accent_color.name() - self.setStyleSheet( - f""" + self.setStyleSheet(f""" #NotificationToast {{ background: {card_bg.name(QtGui.QColor.HexArgb)}; border-radius: 12px; @@ -406,18 +401,15 @@ class NotificationToast(QFrame): font-size: 14px; }} #NotificationToast QPushButton:hover {{ color: {btn_hover}; }} - """ - ) + """) # traceback panel colours trace_bg = "#1e1e1e" if theme == "dark" else "#f0f0f0" - self.trace_view.setStyleSheet( - f""" + self.trace_view.setStyleSheet(f""" background:{trace_bg}; color:{palette['body']}; border:none; border-radius:8px; - """ - ) + """) # icon glyph vs badge background: darker badge, lighter icon in light mode icon_fg = "#ffffff" if theme == "light" else self._accent_color.name() @@ -438,15 +430,13 @@ class NotificationToast(QFrame): else: badge_bg.setAlphaF(0.30) icon_bg = badge_bg.name(QtGui.QColor.HexArgb) - self._icon_btn.setStyleSheet( - f""" + self._icon_btn.setStyleSheet(f""" QToolButton {{ background: {icon_bg}; border: none; border-radius: 20px; }} - """ - ) + """) # stronger accent wash in light mode, slightly stronger in dark too self._accent_alpha = 110 if theme == "light" else 60 @@ -593,8 +583,7 @@ class NotificationCentre(QScrollArea): self.setWidgetResizable(True) # transparent background so only the toast cards are visible self.setAttribute(QtCore.Qt.WA_TranslucentBackground, True) - self.setStyleSheet( - """ + self.setStyleSheet(""" #NotificationCentre { background: transparent; } #NotificationCentre QScrollBar:vertical { background: transparent; @@ -610,8 +599,7 @@ class NotificationCentre(QScrollArea): #NotificationCentre QScrollBar::sub-line:vertical { height: 0; } #NotificationCentre QScrollBar::add-page:vertical, #NotificationCentre QScrollBar::sub-page:vertical { background: transparent; } - """ - ) + """) self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.setFrameShape(QtWidgets.QFrame.NoFrame) self.setFixedWidth(fixed_width) @@ -958,8 +946,7 @@ class NotificationIndicator(QWidget): self._group.buttonToggled.connect(self._button_toggled) # minimalistic look: no frames or backgrounds on the buttons - self.setStyleSheet( - """ + self.setStyleSheet(""" QToolButton { border: none; background: transparent; @@ -970,8 +957,7 @@ class NotificationIndicator(QWidget): background: rgba(255, 255, 255, 40); font-weight: 600; } - """ - ) + """) # initial state: none checked (auto‑dismiss behaviour) for k in kinds: diff --git a/bec_widgets/widgets/control/device_manager/components/available_device_resources/available_device_group.py b/bec_widgets/widgets/control/device_manager/components/available_device_resources/available_device_group.py index 96759d7b..bf5746c9 100644 --- a/bec_widgets/widgets/control/device_manager/components/available_device_resources/available_device_group.py +++ b/bec_widgets/widgets/control/device_manager/components/available_device_resources/available_device_group.py @@ -51,8 +51,7 @@ class _DeviceEntryWidget(QFrame): self.setToolTip(self._rich_text()) def _rich_text(self): - return dedent( - f""" + return dedent(f"""

{self._device_spec.name}:

@@ -60,8 +59,7 @@ class _DeviceEntryWidget(QFrame):
description: {self._device_spec.description}
enabled: {self._device_spec.enabled}
read only: {self._device_spec.readOnly}
- """ - ) + """) def setup_title_layout(self, device_spec: HashableDevice): self._title_layout = QHBoxLayout() diff --git a/bec_widgets/widgets/dap/lmfit_dialog/lmfit_dialog.py b/bec_widgets/widgets/dap/lmfit_dialog/lmfit_dialog.py index 68870b60..b9ab384b 100644 --- a/bec_widgets/widgets/dap/lmfit_dialog/lmfit_dialog.py +++ b/bec_widgets/widgets/dap/lmfit_dialog/lmfit_dialog.py @@ -275,12 +275,10 @@ class LMFitDialog(BECWidget, QWidget): button.setEnabled(True) else: button.setEnabled(False) - button.setStyleSheet( - f""" + button.setStyleSheet(f""" QPushButton:enabled {{ background-color: {self._accent_colors.success.name()};color: white; }} QPushButton:disabled {{ background-color: grey;color: white; }} - """ - ) + """) self.action_buttons[param_name] = button layout = QVBoxLayout() layout.addWidget(self.action_buttons[param_name]) diff --git a/bec_widgets/widgets/editors/jupyter_console/jupyter_console.py b/bec_widgets/widgets/editors/jupyter_console/jupyter_console.py index e5322689..40733201 100644 --- a/bec_widgets/widgets/editors/jupyter_console/jupyter_console.py +++ b/bec_widgets/widgets/editors/jupyter_console/jupyter_console.py @@ -47,15 +47,13 @@ class BECJupyterConsole(RichJupyterWidget): # pragma: no cover: ) def _init_bec_kernel(self): - self.execute( - """ + self.execute(""" from bec_ipython_client.main import BECIPythonClient bec = BECIPythonClient() bec.start() dev = bec.device_manager.devices if bec else None scans = bec.scans if bec else None - """ - ) + """) def _cleanup_bec(self): if getattr(self, "ipyclient", None) is not None and self.inprocess is True: diff --git a/bec_widgets/widgets/editors/monaco/monaco_widget.py b/bec_widgets/widgets/editors/monaco/monaco_widget.py index b1ec71e6..3b2a9652 100644 --- a/bec_widgets/widgets/editors/monaco/monaco_widget.py +++ b/bec_widgets/widgets/editors/monaco/monaco_widget.py @@ -362,8 +362,7 @@ if __name__ == "__main__": # pragma: no cover widget.set_language("python") widget.set_theme("vs-dark") widget.editor.set_minimap_enabled(False) - widget.set_text( - """ + widget.set_text(""" import numpy as np from typing import TYPE_CHECKING @@ -380,8 +379,7 @@ if TYPE_CHECKING: # This is a comment def hello_world(): print("Hello, world!") - """ - ) + """) widget.set_highlighted_lines(1, 3) widget.show() qapp.exec_() diff --git a/bec_widgets/widgets/progress/ring_progress_bar/ring_progress_settings_cards.py b/bec_widgets/widgets/progress/ring_progress_bar/ring_progress_settings_cards.py index 405646b0..e3c0a999 100644 --- a/bec_widgets/widgets/progress/ring_progress_bar/ring_progress_settings_cards.py +++ b/bec_widgets/widgets/progress/ring_progress_bar/ring_progress_settings_cards.py @@ -44,14 +44,12 @@ class RingCardWidget(QFrame): self.setObjectName("RingCardWidget") bg = self._get_theme_color("BORDER") - self.setStyleSheet( - f""" + self.setStyleSheet(f""" #RingCardWidget {{ border: 1px solid {bg.name() if bg else '#CCCCCC'}; border-radius: 4px; }} - """ - ) + """) layout = QVBoxLayout(self) layout.setContentsMargins(8, 8, 8, 8) diff --git a/bec_widgets/widgets/services/bec_queue/bec_queue.py b/bec_widgets/widgets/services/bec_queue/bec_queue.py index c0bba710..5ac32814 100644 --- a/bec_widgets/widgets/services/bec_queue/bec_queue.py +++ b/bec_widgets/widgets/services/bec_queue/bec_queue.py @@ -289,14 +289,12 @@ class BECQueue(BECWidget, CompactPopupWidget): abort_button.button.setIcon( material_icon("cancel", color="#cc181e", filled=True, convert_to_pixmap=False) ) - abort_button.setStyleSheet( - """ + abort_button.setStyleSheet(""" QPushButton { background-color: transparent; border: none; } - """ - ) + """) return abort_button diff --git a/bec_widgets/widgets/utility/ide_explorer/ide_explorer.py b/bec_widgets/widgets/utility/ide_explorer/ide_explorer.py index 2c19a176..c3919608 100644 --- a/bec_widgets/widgets/utility/ide_explorer/ide_explorer.py +++ b/bec_widgets/widgets/utility/ide_explorer/ide_explorer.py @@ -227,13 +227,11 @@ class IDEExplorer(BECWidget, QWidget): try: # Create the file with a basic template with open(file_path, "w", encoding="utf-8") as f: - f.write( - f""" + f.write(f""" \"\"\" {filename} - Created at {datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')} \"\"\" -""" - ) +""") except Exception as e: # Show error if file creation failed @@ -281,8 +279,7 @@ class IDEExplorer(BECWidget, QWidget): try: # Create the file with a macro function template with open(file_path, "w", encoding="utf-8") as f: - f.write( - f'''""" + f.write(f'''""" {function_name} macro - Created at {datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')} """ @@ -296,8 +293,7 @@ def {function_name}(): print("Executing macro: {function_name}") # TODO: Add your macro code here pass -''' - ) +''') # Refresh the macro tree to show the new function macro_dir_section.content_widget.refresh() diff --git a/tests/unit_tests/test_developer_view.py b/tests/unit_tests/test_developer_view.py index f4b756fc..5efa52ae 100644 --- a/tests/unit_tests/test_developer_view.py +++ b/tests/unit_tests/test_developer_view.py @@ -38,8 +38,7 @@ def developer_view(qtbot, mocked_client): def temp_python_file(): """Create a temporary Python file for testing.""" with tempfile.NamedTemporaryFile(mode="w", suffix=".py", delete=False) as f: - f.write( - """# Test Python file + f.write("""# Test Python file import os import sys @@ -48,8 +47,7 @@ def test_function(): if __name__ == "__main__": print(test_function()) -""" - ) +""") temp_file_path = f.name yield temp_file_path diff --git a/tests/unit_tests/test_generate_cli_client.py b/tests/unit_tests/test_generate_cli_client.py index 2a7a9ea2..9229e3c7 100644 --- a/tests/unit_tests/test_generate_cli_client.py +++ b/tests/unit_tests/test_generate_cli_client.py @@ -88,8 +88,7 @@ def test_client_generator_with_black_formatting(): generator.generate_client(container) # Format the expected output with black to ensure it matches the generator output - expected_output = dedent( - '''\ + expected_output = dedent('''\ # This file was automatically generated by generate_cli.py # type: ignore @@ -174,8 +173,7 @@ def test_client_generator_with_black_formatting(): """ Set the amplitude of the waveform. """ - ''' - ) + ''') expected_output_formatted = black.format_str( expected_output, mode=black.FileMode(line_length=100) diff --git a/tests/unit_tests/test_ide_explorer.py b/tests/unit_tests/test_ide_explorer.py index cfdf3d5f..3f415edf 100644 --- a/tests/unit_tests/test_ide_explorer.py +++ b/tests/unit_tests/test_ide_explorer.py @@ -68,21 +68,17 @@ def test_shared_macros_section_with_files(ide_explorer, tmpdir): """Test that shared macros section is created when plugin directory has files""" # Create dummy shared macro files shared_macros_dir = tmpdir.mkdir("shared_macros") - shared_macros_dir.join("shared_macro1.py").write( - """ + shared_macros_dir.join("shared_macro1.py").write(""" def shared_function1(): return "shared1" def shared_function2(): return "shared2" -""" - ) - shared_macros_dir.join("utilities.py").write( - """ +""") + shared_macros_dir.join("utilities.py").write(""" def utility_function(): return "utility" -""" - ) +""") with mock.patch.object(ide_explorer, "_get_plugin_dir") as mock_get_plugin_dir: mock_get_plugin_dir.return_value = str(shared_macros_dir) diff --git a/tests/unit_tests/test_macro_tree_widget.py b/tests/unit_tests/test_macro_tree_widget.py index 501836cb..f29934e2 100644 --- a/tests/unit_tests/test_macro_tree_widget.py +++ b/tests/unit_tests/test_macro_tree_widget.py @@ -20,8 +20,7 @@ def temp_macro_files(tmpdir): # Create a simple macro file with functions macro_file1 = macro_dir / "test_macros.py" - macro_file1.write_text( - ''' + macro_file1.write_text(''' def test_macro_function(): """A test macro function.""" return "test" @@ -34,13 +33,11 @@ class TestClass: """This class should be ignored.""" def method(self): pass -''' - ) +''') # Create another macro file macro_file2 = macro_dir / "utils_macros.py" - macro_file2.write_text( - ''' + macro_file2.write_text(''' def utility_function(): """A utility function.""" pass @@ -48,37 +45,30 @@ def utility_function(): def deprecated_function(): """Old function.""" return None -''' - ) +''') # Create a file with no functions (should be ignored) empty_file = macro_dir / "empty.py" - empty_file.write_text( - """ + empty_file.write_text(""" # Just a comment x = 1 y = 2 -""" - ) +""") # Create a file starting with underscore (should be ignored) private_file = macro_dir / "_private.py" - private_file.write_text( - """ + private_file.write_text(""" def private_function(): return "private" -""" - ) +""") # Create a file with syntax errors error_file = macro_dir / "error_file.py" - error_file.write_text( - """ + error_file.write_text(""" def broken_function( # Missing closing parenthesis and colon pass -""" - ) +""") return macro_dir @@ -406,13 +396,11 @@ class TestMacroTreeRefresh: # Add a new macro file new_file = temp_macro_files / "new_macros.py" - new_file.write_text( - ''' + new_file.write_text(''' def new_function(): """A new function.""" return "new" -''' - ) +''') # Refresh the tree macro_tree.refresh() @@ -439,14 +427,12 @@ def new_function(): # Modify the file to add a new function with open(test_file_path, "a") as f: - f.write( - ''' + f.write(''' def newly_added_function(): """A newly added function.""" return "added" -''' - ) +''') # Refresh just this file macro_tree.refresh_file_item(test_file_path)