Improve stubtest handling of expected dunder methods (#21764)
Stubtest currently suppresses diagnostics regarding missing dunder methods whenever the runtime attribute is a `WrapperDescriptorType`. This is because `WrapperDescriptorType` dunders are often not actually callable at runtime, so suppressing these diagnostics avoids many false positives. However, it also hides genuine omissions such as `collections.deque.__rmul__` ([typeshed#16055](https://github.com/python/typeshed/pull/16055)). This PR keeps the existing suppression in the general case while reporting missing methods that the stub gives us a reason to expect: - If a stub class has a `__add__` method, a diagnostic regarding a missing `__radd__` method is probably _not_ a false positive - If a a stub class has a `__lt__` method, a diagnostic regarding a missing `__gt__` method is probably _not_ a false positive - If a stub class inherits from `Mapping`, diagnostics regarding missing `__or__`, `__ror__` or `__ior__` are probably _not_ false positives - If a stub class inherits from `Sequence`, diagnostics regarding missing `__mul__`, `__rmul__` or `__imul__` methods are probably _not_ false positives. There may be more heuristics we could add similar to these. These were just the ones I/Codex could think of.
A
Alex Waygood committed
630b101fbec8af5ecdb0a17d7886bb6b90fd8bba
Parent: 869d6ef
Committed by GitHub <noreply@github.com>
on 8/1/2026, 11:09:14 PM