[red-knot] Refresh diagnostics when changing related files#17350
[red-knot] Refresh diagnostics when changing related files#17350MichaReiser merged 1 commit intomainfrom
Conversation
|
Yeah, I think we might need to keep track of the diagnostic dependencies ourselves in that case and if any of the dependent file changes, we'll need to refresh the diagnostics for the parent files. This might also become useful and required for caching diagnostics on the server side. |
Yeah, I'm not sure how that would work because we have no way of asking: What files does file X depend on. Only including its direct dependencies isn't good enough. We might have to publish all diagnostics eagerly. I wanted to look into how r-a does that. |
* main: [red-knot] Specialize `str.startswith` for string literals (#17351) [syntax-errors] `yield`, `yield from`, and `await` outside functions (#17298) [red-knot] Refresh diagnostics when changing related files (#17350) Add `Checker::import_from_typing` (#17340) Don't add chaperone space after escaped quote in triple quote (#17216) [red-knot] Silence errors in unreachable type annotations / class bases (#17342)
Summary
Given:
main.py:foo.pyRed Knot reports an unresolved import diagnostic in
main.pybecausefoodoesn't exportFoo.Renaming the class
Foinfoo.pytoFooshould refresh the diagnsotics inmain.py.It turns out, that this is a fairly easy change. All that was necessary is to set
inter_file_dependenciesin the server registration options to true.We'll need a different solution for publish diagnostics but Red Knot doesn't yet support publish diagnostics (astral-sh/ty#79)
Test Plan
Screen.Recording.2025-04-11.at.14.46.47.mov