[ty] Checking files without extension#21867
Merged
MichaReiser merged 3 commits intomainfrom Dec 10, 2025
Merged
Conversation
Diagnostic diff on typing conformance testsNo changes detected when running ty on typing conformance tests ✅ |
|
Gankra
approved these changes
Dec 9, 2025
Contributor
Gankra
left a comment
There was a problem hiding this comment.
Ah good, this is roughly what I was expecting! Not the most thorough review (migraine winning)
| .extension() | ||
| .and_then(PySourceType::try_from_extension) | ||
| .is_none() | ||
| { |
Contributor
There was a problem hiding this comment.
Hmm this check seems kinda adhoc/brittle
Member
Author
There was a problem hiding this comment.
Can't disagree. All our 'Keep the world in sync with salsa' is a bit brittle. Not sure what else to do.
BurntSushi
added a commit
that referenced
this pull request
Feb 6, 2026
Previously, we were only setting the check mode on a project if the diagnostic mode was `workspace`. While the diagnostic mode defaults to `OpenFilesOnly`, the _check mode_ on a ty project defaults to `AllFiles` (i.e., workspace). The result is that projects were always configured in `AllFiles` check mode, making it impossible to set the check mode to `OpenFilesOnly`. Confusingly, this is _distinct_ from the global settings diagnostic mode, which could actually be different thant he check mode on the individual projects! This did cause one test failure: an end-to-end test checking that changing the language of a file resulted in the LSP picking up that change. e.g., Going from Python to non-Python should result in no diagnostics. This was added in #21867, but I believe the change was incomplete: when a `didOpen` notification is received, we were unconditionally adding the file to the project state without checking its extension. The test still "worked" precisely because of the `AllFiles` vs `OpenFilesOnly` confusion. That is, the server defaulted to `OpenFilesOnly`, but the project defaulted to `AllFiles`. This in turn made it so the file was an "open file" and not actually picked up from a directory scan. That in turn led to `should_check_file` returning false, since the `AllFiles` mode explicitly ignores "open files." Ref astral-sh/ty#2616
BurntSushi
added a commit
that referenced
this pull request
Feb 9, 2026
Previously, we were only setting the check mode on a project if the diagnostic mode was `workspace`. While the diagnostic mode defaults to `OpenFilesOnly`, the _check mode_ on a ty project defaults to `AllFiles` (i.e., workspace). The result is that projects were always configured in `AllFiles` check mode, making it impossible to set the check mode to `OpenFilesOnly`. Confusingly, this is _distinct_ from the global settings diagnostic mode, which could actually be different thant he check mode on the individual projects! This did cause one test failure: an end-to-end test checking that changing the language of a file resulted in the LSP picking up that change. e.g., Going from Python to non-Python should result in no diagnostics. This was added in #21867, but I believe the change was incomplete: when a `didOpen` notification is received, we were unconditionally adding the file to the project state without checking its extension. The test still "worked" precisely because of the `AllFiles` vs `OpenFilesOnly` confusion. That is, the server defaulted to `OpenFilesOnly`, but the project defaulted to `AllFiles`. This in turn made it so the file was an "open file" and not actually picked up from a directory scan. That in turn led to `should_check_file` returning false, since the `AllFiles` mode explicitly ignores "open files." Ref astral-sh/ty#2616
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds support for checking files without extensions if they're passed by name on the CLI or
if the user selects
Pythonas the language in their editor.Fixes astral-sh/ty#1692
Note: We don't yet support excluding a file that has a
.pyextensionif the user selects a non-Python language in their editor but I consider this a separate change.
Test Plan
Added end to end tests