Repository navigation
Report the files a session read - #31
Merged
Merged
Conversation
A new `getReadFiles` method returns every file whose content the session has read since `initialize`: the configuration found, every file under the project root (read when ty indexes the project for PEP 723 metadata), and each source, stub, `py.typed` and `.pth` file reached through the search roots. A build system that declares a target's whole import closure as inputs can use it to learn which of them the answer did not depend on. The database runs on a `RecordingSystem` that delegates to `OsSystem` and records each content read, starting before configuration discovery. ty does not necessarily read a cached file again, so the set is cumulative per session rather than per request. A read that finds no file is not recorded, since ty tries configuration files by reading them.
…-files-ty-read # Conflicts: # CLAUDE.md # src/main.rs # src/protocol.rs # tests/integration/main.rs
Indexing reads only the Python files the src settings and ignore files admit, and a notebook only when a request names it. The test now asks for a notebook and expects it listed, covering read_to_notebook.
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.
A build that runs ty-types once per target has to declare the target's whole transitive closure as inputs: every dependency's sources and each wheel's
site-packages. An edit anywhere in it re-runs the analysis, even in a module the target never imports. Bazel ignores inputs an action reports as unused (unused_inputs_list), but only if the tool can say what it read.ty is lazy, so what it reads is far smaller than the static import closure a build would otherwise have to assume. Measured on two single-file targets against a closure that follows every import, including conditional and function-local ones:
site-packagesfiles ty readrequests,pydanticpandasA recording
System, queried per sessionSalsa exposes neither a query's input dependencies nor an event for reading one, but ty reaches files through its
System. The database runs on aRecordingSystemthat records each content read, from before configuration discovery soty.toml,pyproject.tomlandpyvenv.cfgare included. A read that finds no file is left out: ty tries configuration files in every ancestor by reading them.The set is cumulative since
initializeand answered by its own method rather than on eachgetTypes. A file cached by an earlier request is not read again, so a per-request delta would under-report. A file whose inference panics still counts, and a client asks once per session instead of threading the list through every response.Not changed here
CheckMode::OpenFileswould avoid that, but it changesshould_check_filefor existing clients.uvreads whenTY_UVis set, bypassSystem. The README names both as exceptions to the guarantee.read_files_name_what_inference_read_and_not_the_rest_of_a_search_rootputs a dependency in a search root outside the project. It asserts the imported module andty.tomlare listed, while an unimported sibling and the missingpyproject.tomlare not. It was mutation-checked: the test fails if recording is dropped, and fails if directory listings count as reads.