[ty] Fix find references for type defined in stub by MichaReiser · Pull Request #21732 · astral-sh/ruff (original) (raw)

@MichaReiser

ty failed to return any references for a type defined in a stub where there's also a definition in a non-stub file.

The underlying issue was that find_references resolved the name to "go-to definition" whereas the visitor resolved the declaration, which can resolve to a different file and location.

This fix uses go to declaration in both steps. I don't think it really matters whether we use go to declaration or go to definition because both should resolve to the same references. I picked go to declaration because it requires less work (no stub mapping)

@MichaReiser added server

Related to the LSP server

ty

Multi-file analysis & type inference

labels

Dec 1, 2025

@MichaReiser MichaReiser deleted the micha/fix-references-for-type-defined-in-stub branch

December 1, 2025 16:53

dcreager added a commit that referenced this pull request

Dec 2, 2025

@dcreager

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})