-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[ty] Fix incorrect docstring in call signature completion #20021
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Diagnostic diff on typing conformance testsNo changes detected when running ty on typing conformance tests ✅ |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense to me!
I agree that we need to do some work cleaning up Type::bindings()
, but I think both @sharkdp and I have tried several times at this point and every time we found it surprisingly hard 🙃 so this is definitely the easier fix for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
I'll give @carljm a chance to chime in, as he reasoned that we should remove |
I do think that's what we should do eventually, but it doesn't have to be done right now -- this fix improves the behavior in the short term and I don't think makes anything more difficult for removing the definition in future, so I'm in favor of it. (Also it removes code, and all else equal I'm always in favor of that 😆 ) |
I'm gonna land this since it's a important/pervasive bugfix, makes it easier to test/debug other function handling features. |
…20021) ## 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 `CallableType`s 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 https://github.com/astral-sh/ruff/blob/39ee71c2a57bd6c51482430ba8bfe3728b4ca443/crates/ty_python_semantic/src/types.rs#L4582-L4586 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 astral-sh#19615 ## Test Plan https://github.com/user-attachments/assets/248d1cb1-12fd-4441-adab-b7e0866d23eb
Summary
This PR fixes astral-sh/ty#1071
The core issue is that
CallableType
is a salsa interned butSignature
(whichCallableType
stores) ignores theDefinition
in itsEq
andHash
implementation.This PR tries to simplest fix by removing the custom
Eq
andHash
implementation. The main downside of this fix is that it can increase memory usage becauseCallableType
s that are equal except for theirDefinition
are now interned separately.The alternative is to remove
Definition
fromCallableType
and instead, callbindings
directly on the callee (call_expression.func). However, this would requireaddressing the TODO
here
ruff/crates/ty_python_semantic/src/types.rs
Lines 4582 to 4586 in 39ee71c
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