Skip to content

Commit

Permalink
Type check suggestor
Browse files Browse the repository at this point in the history
  • Loading branch information
eivindjahren committed Jun 10, 2024
1 parent 3f42de1 commit 9b517d2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 24 deletions.
4 changes: 0 additions & 4 deletions .mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@ ignore_errors = True
ignore_missing_imports = True
ignore_errors = True

[mypy-ert.gui.suggestor.*]
ignore_missing_imports = True
ignore_errors = True

[mypy-ert.gui.tools.*]
ignore_missing_imports = True
ignore_errors = True
Expand Down
27 changes: 12 additions & 15 deletions src/ert/gui/suggestor/_suggestor_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
QSizePolicy,
QWidget,
)
from typing_extensions import Self

from ._colors import (
BLUE_BACKGROUND,
Expand All @@ -23,7 +24,7 @@
)

if TYPE_CHECKING:
from ert.config import ErrorInfo
from ert.config import ErrorInfo, WarningInfo


def _svg_icon(image_name: str) -> QtSvg.QSvgWidget:
Expand All @@ -42,7 +43,7 @@ def __init__(
info: ErrorInfo,
) -> None:
super().__init__()
self.setAttribute(Qt.WA_StyledBackground)
self.setAttribute(Qt.WidgetAttribute.WA_StyledBackground)
self.setStyleSheet(
f"""
background-color: {bg_color};
Expand Down Expand Up @@ -71,29 +72,25 @@ def __init__(
+ "</div>"
)
self.lbl.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
self.lbl.setTextInteractionFlags(Qt.TextSelectableByMouse)
self.lbl.setTextInteractionFlags(Qt.TextInteractionFlag.TextSelectableByMouse)
self.lbl.setWordWrap(True)

self.hbox = QHBoxLayout()
self.hbox.setContentsMargins(16, 16, 16, 16)
self.hbox.addWidget(self.icon, alignment=Qt.AlignTop)
self.hbox.addWidget(self.lbl, alignment=Qt.AlignTop)
self.hbox.addWidget(self.icon, alignment=Qt.AlignmentFlag.AlignTop)
self.hbox.addWidget(self.lbl, alignment=Qt.AlignmentFlag.AlignTop)
self.setLayout(self.hbox)

@classmethod
def error_msg(cls, info):
return SuggestorMessage(
"Error: ", RED_TEXT, RED_BACKGROUND, _svg_icon("error"), info
)
def error_msg(cls, info: ErrorInfo) -> Self:
return cls("Error: ", RED_TEXT, RED_BACKGROUND, _svg_icon("error"), info)

@classmethod
def warning_msg(cls, info):
return SuggestorMessage(
def warning_msg(cls, info: WarningInfo) -> Self:
return cls(
"Warning: ", YELLOW_TEXT, YELLOW_BACKGROUND, _svg_icon("warning"), info
)

@classmethod
def deprecation_msg(cls, info):
return SuggestorMessage(
"Deprecation: ", BLUE_TEXT, BLUE_BACKGROUND, _svg_icon("bell"), info
)
def deprecation_msg(cls, info: WarningInfo) -> Self:
return cls("Deprecation: ", BLUE_TEXT, BLUE_BACKGROUND, _svg_icon("bell"), info)
10 changes: 5 additions & 5 deletions src/ert/gui/suggestor/suggestor.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ def _help_panel(self, help_links: Dict[str, str]) -> QFrame:
def _problem_area(
self,
errors: List[ErrorInfo],
warnings: List[ErrorInfo],
deprecations: List[ErrorInfo],
warnings: List[WarningInfo],
deprecations: List[WarningInfo],
) -> QWidget:
problem_area = QWidget(parent=self)
problem_area.setContentsMargins(0, 0, 0, 0)
Expand Down Expand Up @@ -210,7 +210,7 @@ def run_pressed() -> None:

run.setObjectName("run_ert_button")
run.pressed.connect(run_pressed)
give_up.pressed.connect(self.close)
give_up.pressed.connect(self.close) # type: ignore
buttons = QWidget(parent=self)
buttons_layout = QHBoxLayout()
buttons_layout.insertStretch(-1, -1)
Expand All @@ -223,8 +223,8 @@ def run_pressed() -> None:
def _messages(
self,
errors: List[ErrorInfo],
warnings: List[ErrorInfo],
deprecations: List[ErrorInfo],
warnings: List[WarningInfo],
deprecations: List[WarningInfo],
) -> QScrollArea:
CARD_WIDTH = 450
CARD_HEIGHT = 220
Expand Down

0 comments on commit 9b517d2

Please sign in to comment.