Skip to content

Commit d994068

Browse files
committed
Resolve mypy findings
1 parent ed814dd commit d994068

File tree

1 file changed

+23
-19
lines changed

1 file changed

+23
-19
lines changed

src/ert/gui/main_window.py

+23-19
Original file line numberDiff line numberDiff line change
@@ -117,24 +117,25 @@ def __init__(
117117
self.__add_tools_menu()
118118
self.__add_help_menu()
119119

120-
def select_central_widget(self):
120+
def select_central_widget(self) -> None:
121121
actor = self.sender()
122-
index_name = actor.property("index")
122+
if actor:
123+
index_name = actor.property("index")
123124

124-
if index_name == "Create plot" and not self._plot_window:
125-
self._plot_window = PlotWindow(self.config_file, self)
126-
self.central_layout.addWidget(self._plot_window)
127-
self.central_panels_map["Create plot"] = self._plot_window
125+
if index_name == "Create plot" and not self._plot_window:
126+
self._plot_window = PlotWindow(self.config_file, self)
127+
self.central_layout.addWidget(self._plot_window)
128+
self.central_panels_map["Create plot"] = self._plot_window
128129

129-
if index_name == "Simulation status":
130-
# select the only available simulation
131-
for k, v in self.central_panels_map.items():
132-
if isinstance(v, RunDialog):
133-
index_name = k
134-
break
130+
if index_name == "Simulation status":
131+
# select the only available simulation
132+
for k, v in self.central_panels_map.items():
133+
if isinstance(v, RunDialog):
134+
index_name = k
135+
break
135136

136-
for i, widget in self.central_panels_map.items():
137-
widget.setVisible(i == index_name)
137+
for i, widget in self.central_panels_map.items():
138+
widget.setVisible(i == index_name)
138139

139140
@Slot(object)
140141
def slot_add_widget(self, run_dialog: RunDialog) -> None:
@@ -151,8 +152,9 @@ def add_sim_run_option(datetime: str) -> None:
151152
menu = self.results_button.menu()
152153
if menu:
153154
act = menu.addAction(datetime)
154-
act.setProperty("index", datetime)
155-
act.triggered.connect(self.select_central_widget)
155+
if act:
156+
act.setProperty("index", datetime)
157+
act.triggered.connect(self.select_central_widget)
156158

157159
if self.run_dialog_counter == 2:
158160
# swap from button to menu selection
@@ -187,7 +189,9 @@ def post_init(self) -> None:
187189
self.plugins_tool = PluginsTool(plugin_handler, self.notifier, self.ert_config)
188190
if self.plugins_tool:
189191
self.plugins_tool.setParent(self)
190-
self.menuBar().addMenu(self.plugins_tool.get_menu())
192+
menubar = self.menuBar()
193+
if menubar:
194+
menubar.addMenu(self.plugins_tool.get_menu())
191195

192196
self._manage_experiments_panel = ManageExperimentsPanel(
193197
self.ert_config,
@@ -202,7 +206,7 @@ def post_init(self) -> None:
202206
def _add_sidebar_button(self, name: str, icon: QIcon) -> QPushButton:
203207
button = QPushButton(self.side_frame)
204208
button.setFixedSize(60, 60)
205-
button.setCursor(QCursor(Qt.PointingHandCursor))
209+
button.setCursor(QCursor(Qt.CursorShape.PointingHandCursor))
206210
button.setStyleSheet(BUTTON_STYLE_SHEET)
207211
pad = 30
208212
icon_size = QSize(button.size().width() - pad, button.size().height() - pad)
@@ -227,7 +231,7 @@ def __add_help_menu(self) -> None:
227231
help_link_item = help_menu.addAction(menu_label)
228232
assert help_link_item is not None
229233
help_link_item.setMenuRole(QAction.MenuRole.ApplicationSpecificRole)
230-
help_link_item.triggered.connect(functools.partial(webbrowser.open, link))
234+
help_link_item.triggered.connect(functools.partial(webbrowser.open, link)) # type: ignore
231235

232236
show_about = help_menu.addAction("About")
233237
assert show_about is not None

0 commit comments

Comments
 (0)