Skip to content

Conversation

MichaReiser
Copy link
Member

Summary

I noticed when playing with the extension that ty always reparses all AST nodes
after I changed the open files in the editor.

The reason for this is that check_file_impl depends on db.open_files
to check if it should evict the AST or not. However, that means that all
project files will be rechecked after changing the open project files.

This PR prevents this by moving the AST eviction out of the
check_file_impl function. This has the downside
that it requires an extra parsed_module call but that
should be relatively cheap (we make thousends of those when checking a single file).

Test Plan

I verified that opening an other file doesn't result in re-checking every single project file.

@MichaReiser MichaReiser added server Related to the LSP server ty Multi-file analysis & type inference labels Jul 21, 2025
@MichaReiser MichaReiser requested review from ibraheemdev and dhruvmanila and removed request for dcreager, sharkdp, AlexWaygood and carljm July 21, 2025 13:33
Copy link
Contributor

github-actions bot commented Jul 21, 2025

mypy_primer results

No ecosystem changes detected ✅
No memory usage changes detected ✅

@MichaReiser MichaReiser force-pushed the micha/fix-reparse-open-change branch from 89f1ba6 to be9b1f5 Compare July 21, 2025 13:36
@MichaReiser MichaReiser merged commit 926e833 into main Jul 21, 2025
37 checks passed
@MichaReiser MichaReiser deleted the micha/fix-reparse-open-change branch July 21, 2025 16:05
dcreager added a commit that referenced this pull request Jul 21, 2025
…ability

* origin/main:
  [ty] Expansion of enums into unions of literals (#19382)
  [ty] Avoid rechecking the entire project when changing the opened files (#19463)
  [ty] Add warning for unknown `TY_MEMORY_REPORT` value (#19465)
dcreager added a commit that referenced this pull request Jul 22, 2025
* main: (76 commits)
  Move fix suggestion to subdiagnostic (#19464)
  [ty] Implement non-stdlib stub mapping for classes and functions (#19471)
  [ty] Disallow illegal uses of `ClassVar` (#19483)
  [ty] Disallow `Final` in function parameter/return-type annotations (#19480)
  [ty] Extend `Final` test suite (#19476)
  [ty] Minor change to diagnostic message for invalid Literal uses (#19482)
  [ty] Detect illegal non-enum attribute accesses in Literal annotation (#19477)
  [ty] Reduce size of `TypeInference` (#19435)
  Run MD tests for Markdown-only changes (#19479)
  Revert "[ty] Detect illegal non-enum attribute accesses in Literal annotation"
  [ty] Detect illegal non-enum attribute accesses in Literal annotation
  [ty] Added semantic token support for more identifiers (#19473)
  [ty] Make tuple subclass constructors sound (#19469)
  [ty] Pass down specialization to generic dataclass bases (#19472)
  [ty] Garbage-collect reachability constraints (#19414)
  [ty] Implicit instance attributes declared `Final` (#19462)
  [ty] Expansion of enums into unions of literals (#19382)
  [ty] Avoid rechecking the entire project when changing the opened files (#19463)
  [ty] Add warning for unknown `TY_MEMORY_REPORT` value (#19465)
  [ty] Sync vendored typeshed stubs (#19461)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
server Related to the LSP server ty Multi-file analysis & type inference
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants