Skip to main content

SKIPPED_DUNDERS

Constant SKIPPED_DUNDERS 

const SKIPPED_DUNDERS: [&str; 13];
Expand description

Attributes every #[pyclass] carries that the stub does not restate.

Deliberately short, and everything not on it is an error rather than a silent omission: a __init__ appearing here would mean a binding grew a #[new] constructor, which is public API and must be typed.

The rule for admitting one is narrow: object already declares it, with the signature the binding gives it. __repr__/__str__ return str and __eq__/__ne__/__hash__ are (object) -> bool and () -> int, so a stub line for any of them would restate object’s and tell a type checker nothing it does not already know. Everything else — __len__, __iter__, an operator, a #[new] — narrows or adds a protocol and must be typed.

The four ordering dunders are on the list for a subtler reason: CPython backs all six comparisons with the one tp_richcompare slot, so a #[pyclass] that defines only __eq__ still grows __lt__, __le__, __gt__ and __ge__ in its __dict__ — and they return NotImplemented, which is object’s behaviour and raises TypeError at the call site exactly as object’s do. They are an artefact of the slot, not API this binding added. A class that means to be ordered implements __lt__ itself, and this table cannot tell the two apart; a stub line for an ordering it does not have would be the worse error, so atune_py’s a_frozen_trial_is_a_value_not_an_identity pins the TypeError instead.