Skip to content

Model reflected division slots without stubtest exceptions #226

Backlog

Description

@altendky

PR #224 leaves the real rtruediv slots on QPoint, QPointF, QSize, and QSizeF unstubbed and adds four exact stubtest exceptions. This is a modeling compromise: runtime exposes these methods, but the tested scalar and value operands return NotImplemented, and reverse division raises TypeError.

Current exceptions:

# SIP exposes these slots, but valid scalar and value operands return
# NotImplemented: reverse division is not a supported operation.
PyQt5.QtCore.QPoint.__rtruediv__
PyQt5.QtCore.QPointF.__rtruediv__
PyQt5.QtCore.QSize.__rtruediv__
PyQt5.QtCore.QSizeF.__rtruediv__

Existing tests preserve rejection of unsupported reverse division:

with pytest.raises(TypeError):
2 / point # type: ignore[operator]
with pytest.raises(TypeError):
2 / point_f # type: ignore[operator]
with pytest.raises(TypeError):
2 / size # type: ignore[operator]
with pytest.raises(TypeError):
2 / size_f # type: ignore[operator]

Investigate precise annotations for the exposed hooks and how current type checkers handle NotImplemented in reflected operators. Representing the methods should preserve accurate typing of direct hook calls and rejection of unsupported arithmetic expressions.

Completion criteria:

  • Verify the direct-call behavior and return values for all four classes and relevant operand types.
  • Add accurate hook declarations and static/runtime regressions, or identify and track the checker limitation preventing an accurate model.
  • Remove the four exact exceptions when the hooks can be represented without claiming that reverse division succeeds.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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