-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[ty] Add virtual files to the only project database #19322
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
|
|
Actually, this is not an "internal" change as the server now starts checking virtual files in workspace diagnostic mode. |
I think the reason the other case isn't working is that the file doesn't exists on disk and so the Now, the linked PR does fix the issue here which I'm not exactly sure how. |
I don't think this will be necessary. We only use the default database so that we can provide basic LSP features for those files. I don't think we have to provide diagnostics.
I'm not sure where this message is logged which makes it difficult to help. It probably makes sense to add a log statement to |
c14535c to
993d565
Compare
|
Somehow, this change is also initializing the default database when I open a virtual file and select the Python language for that virtual file. |
* dcreager/merge-arguments: (223 commits) fix docs Combine CallArguments and CallArgumentTypes [ty] Sync vendored typeshed stubs (#19334) [`refurb`] Make example error out-of-the-box (`FURB122`) (#19297) [refurb] Make example error out-of-the-box (FURB177) (#19309) [ty] ignore errors when reformatting codemodded typeshed (#19332) [ty] Provide docstrings for stdlib APIs when hovering over them in an IDE (#19311) [ty] Add virtual files to the only project database (#19322) Add t-string fixtures for rules that do not need to be modified (#19146) [ty] Remove `FileLookupError` (#19323) [ty] Fix handling of metaclasses in `object.<CURSOR>` completions [ty] Use an interval map for scopes by expression (#19025) [ty] List all `enum` members (#19283) [ty] Handle configuration errors in LSP more gracefully (#19262) [ty] Use python version and path from Python extension (#19012) [`pep8_naming`] Avoid false positives on standard library functions with uppercase names (`N802`) (#18907) Update Rust crate toml to 0.9.0 (#19320) [ty] Fix server version (#19284) Update NPM Development dependencies (#19319) Update taiki-e/install-action action to v2.56.13 (#19317) ...
Summary
Previously, the virtual files were being added to the default database that's present on the session. This is wrong because the default database is for any files that don't belong to any project i.e., they're outside of any projects managed by the server. Virtual files are neither part of the project nor it is outside the projects. This was not the intention as in the initial version, virtual files were being added to the only project database managed by the server.
This PR fixes this by reverting back to the original behavior where virtual files will be added to the only project database present. When support for multiple workspace and project is added, this will require updating (astral-sh/ty#794).
This is required for #19264 because workspace diagnostics doesn't check the default project database yet. Ideally, the default db should be checked as well.
The implementation of this PR means that virtual files are now being included for workspace diagnostics but it doesn't work completely e.g., if I save an untitled file the diagnostics disappears but it doesn't appear back for the (now) saved file on disk as shown in the following video demonstration:
Screen.Recording.2025-07-14.at.14.00.18.mov