[ty] Fix find references for type defined in stub by MichaReiser · Pull Request #21732 · astral-sh/ruff (original) (raw)
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)
added server
Related to the LSP server
Multi-file analysis & type inference
labels
MichaReiser deleted the micha/fix-references-for-type-defined-in-stub branch
dcreager added a commit that referenced this pull request
- origin/main: (67 commits)
Move
Token,TokenKindandTokenstoruff-python-ast(#21760) [ty] Don't confuse multiple occurrences oftyping.Selfwhen binding bound methods (#21754) Use our org-wide Renovate preset (#21759) Deletemy-script.py(#21751) [ty] Moveall_members, and related types/routines, out ofide_support.rs(#21695) [ty] Fix find-references for import aliases (#21736) [ty] add tests for workspaces (#21741) [ty] Stop testing the (brittle) constraint set display implementation (#21743) [ty] Use generator over list comprehension to avoid cast (#21748) [ty] Add a diagnostic for prohibitedNamedTupleattribute overrides (#21717) [ty] Fix subtyping withtype[T]and unions (#21740) Usenpm ci --ignore-scriptseverywhere (#21742) [flake8-simplify] Fix truthiness assumption for non-iterable arguments in tuple/list/set calls (SIM222,SIM223) (#21479) [flake8-use-pathlib] Mark fixes unsafe for return type changes (PTH104,PTH105,PTH109,PTH115) (#21440) [ty] Fix auto-import code action to handle pre-existing import Enable PEP 740 attestations when publishing to PyPI (#21735) [ty] Fix find references for type defined in stub (#21732) Use OIDC instead of codspeed token (#21719) [ty] Excludetyping_extensionsfrom completions unless it's really available [ty] Fix false positives forclass F(Generic[*Ts]): ...(#21723) ...
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 }})