Repository navigation
Description
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:
PyQt5-stubs/stubtest.allowlist
Lines 82 to 87 in 86957b5
| # 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:
PyQt5-stubs/tests/reflected_geometry.py
Lines 37 to 44 in 86957b5
| 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