Skip to content

QMessageBox signature doesn't match. #214

Open
@th3w1zard1

Description

@th3w1zard1

Attempting to send certain kwargs to QMessageBox will exception, while the stubs say it does support it. For example:

filepath_str, _filter = QFileDialog.getSaveFileName(self, "Save As", "", self._saveFilter, "")
if not filepath_str or not filepath_str.strip() or not os.path.exists(filepath_str):
  QMessageBox(
      icon=QMessageBox.Critical,
      title="Failed to add resource",
      text=f"Could not add resource at {filepath_str}: Choose a valid file.",
      parent=None,
      flags=Qt.Window | Qt.Dialog | Qt.WindowStaysOnTopHint,
  ).exec_()

The above code fails on PyQt5 but mypy does not catch it. The following works however:

filepath_str, _filter = QFileDialog.getSaveFileName(self, "Save As", "", self._saveFilter, "")
if not filepath_str or not filepath_str.strip() or not os.path.exists(filepath_str):
  QMessageBox(
      QMessageBox.Critical,
      "Failed to add resource",
      f"Could not add resource at {filepath_str}: Choose a valid file.",
      parent=None,
      flags=Qt.Window | Qt.Dialog | Qt.WindowStaysOnTopHint,
  ).exec_()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions