Preserve parameter references in unopened files Summary: An earlier change fixed incoming call hierarchy for files that the client did not open. It requested `Require::Everything` for every file that depends on the target module. This made the required ASTs available. However, the same helper also serves find references and find implementations. Those requests then performed full analysis on every dependent file. D117389890 (PR) limits that work. Incoming call hierarchy performs full analysis only on files that reference the target. Type hierarchy performs full analysis on its candidate files. Most find-reference requests and all find-implementation requests use only the retained index. This keeps incoming call hierarchy correct and makes common reference requests faster. D117389890 leaves one correctness problem. Parameter references do not use only the index. To find a keyword argument such as `greet(message="Hello")`, Pyrefly scans the caller AST. It also uses bindings to confirm that the keyword resolves to the selected parameter. An unopened file has neither at `Require::Indexing`. Find references therefore omits the keyword argument. Rename can change the parameter definition but leave `message=` unchanged in the unopened caller. This diff requests `Require::Everything` for all dependent files only when the selected definition is a parameter. Other definitions keep the index-only path from D117389890. This restores parameter references and rename without removing the main performance improvement. This diff also removes a duplicate type-hierarchy request for `Require::Everything`. The caller already makes the same request before it reads the candidate files. The tests cover parameter references and parameter rename in an unopened caller file. The call hierarchy test now has two unopened caller files. This verifies that one batch prepares every selected caller file. Reviewed By: stroxler Differential Revision: D117455220 fbshipit-source-id: f8ba135ace020fbcd0e4ba9b0e7509773ba832be
Pyrefly is a type checker and language server for Python, which provides lightning-fast type checking along with IDE features such as code navigation, semantic highlighting, and code completion. It is available as a command-line tool and an extension for popular IDEs and editors such as VSCode, Neovim, Zed, and more.
See the Pyrefly website for full documentation and how to add Pyrefly to your editor of choice.
Pyrefly's current development status is stable.
pyrefly init, silence existing errors with pyrefly suppress, and generate type annotations with pyrefly infer. Start with one file and expand at your own pace.pip install pyreflyPyrefly releases new minor versions (1.x.0) monthly and patch versions in between as-needed for critical fixes. Pyrefly does not follow strict semantic versioning: minor versions contain more significant changes than patch versions, but any version may introduce new type errors and other breaking changes. The pyrefly suppress command can be used to easily silence errors when upgrading to a new version.
If you have questions or would like to report a bug, please create an issue.
See our contributing guide and architecture overview for information on how to contribute to Pyrefly.
Join our Discord to chat about Pyrefly and types. This is also where we hold biweekly office hours.