[ty] Fix incorrect docstring in call signature completion by MichaReiser · Pull Request #20021 · astral-sh/ruff (original) (raw)

Summary

This PR fixes astral-sh/ty#1071

The core issue is that CallableType is a salsa interned but Signature (which CallableType stores) ignores the Definition in its Eq and Hash implementation.

This PR tries to simplest fix by removing the custom Eq and Hash implementation. The main downside of this fix is that it can increase memory usage because CallableTypes that are equal except for their Definition are now interned separately.

The alternative is to remove Definition from CallableType and instead, call bindings directly on the callee (call_expression.func). However, this would require
addressing the TODO

here

// Most class literal constructor calls are handled by `try_call_constructor` and
// not via getting the signature here. This signature can still be used in some
// cases (e.g. evaluating callable subtyping). TODO improve this definition
// (intersection of `__new__` and `__init__` signatures? and respect metaclass
// `__call__`).

This might probably be worth addressing anyway, but is the more involved fix. That's why I opted for removing the custom Eq implementation.

We already "ignore" the definition during normalization, thank's to Alex's work in #19615

Test Plan

Screen.Recording.2025-08-21.at.14.21.06.mov