[ty] Fix goto definition for relative imports in third-party files#22457
[ty] Fix goto definition for relative imports in third-party files#22457MichaReiser merged 1 commit intomainfrom
Conversation
Merging this PR will not alter performanceSummary
Comparing Footnotes
|
|
Uhm what? |
|
Uhh wait but we still have the default database for when config handling fails on init right..? |
That's different and, confusingly, we used the same term for them. We use a fallback db if the initialization of the project's database fails during workspace initialization. But we associate that db with the project's path. The default database was different. We only used it for paths that have no project with which they share a prefix. |
|
Mostly this just leaves me feeling like "god we have to stop tiptoeing around actually handling multiple workspaces in a session". |
c2ee00f to
511478e
Compare
Yeah, I'm also getting more and more to the conclusion that not having to do that would be great
I'm not aware of a situationb where this would be the case. |
Summary
This PR removes our default database handling from ty's LSP.
We used the default database for files that don't belong to any project,
because we want to treat them differently:
This PR removes the default database and:
This fixes an issue where goto definition didn't work in files in the project's virtual environment
for relative imports because the default database uses different search paths than the project.
The only downside that I see using this approach is that ty doesn't warn
about missing imports in non-project files if those modules are available in the project's virtual environment.
If this is a concern, than I think we'll want to use a similar approach to scripts (TBD). Either way, I don't think
we want to use a default database.
Fixes astral-sh/ty#2290
Test Plan
Tested that goto definition now works for projects using
venvas their virtual environment (the example in astral-sh/ty#2290)