Skip to content

Comments

[ty] Handle configuration errors in LSP more gracefully#19262

Merged
MichaReiser merged 2 commits intomainfrom
micha/handle-configuration-errors
Jul 14, 2025
Merged

[ty] Handle configuration errors in LSP more gracefully#19262
MichaReiser merged 2 commits intomainfrom
micha/handle-configuration-errors

Conversation

@MichaReiser
Copy link
Member

@MichaReiser MichaReiser commented Jul 10, 2025

Summary

Up to now, ty crashed if the project configuration contained invalid syntax are was invalid otherwise.

This PR handles this case more gracefully by showing an error popup and falling back to the default settings.
We probably want to mark the database as "in an error state" in the future when the LSP offers more destructive operations
like formatting so that these can be disabled until the configuration errors are resolved.

Closes astral-sh/ty#76

Test Plan

Screen.Recording.2025-07-10.at.15.22.58.mov

@MichaReiser MichaReiser added server Related to the LSP server ty Multi-file analysis & type inference labels Jul 10, 2025
@MichaReiser MichaReiser added server Related to the LSP server ty Multi-file analysis & type inference labels Jul 10, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Jul 10, 2025

mypy_primer results

No ecosystem changes detected ✅
No memory usage changes detected ✅

@codspeed-hq
Copy link

codspeed-hq bot commented Jul 10, 2025

CodSpeed Instrumentation Performance Report

Merging #19262 will not alter performance

Comparing micha/handle-configuration-errors (f2bba75) with main (9002604)

Summary

✅ 40 untouched benchmarks

@MichaReiser MichaReiser requested review from Gankra and dhruvmanila and removed request for AlexWaygood, carljm, dcreager and sharkdp July 10, 2025 13:55
@dhruvmanila
Copy link
Member

We probably want to mark the database as "in an error state" in the future when the LSP offers more destructive operations
like formatting so that these can be disabled until the configuration errors are resolved.

Yeah, I think we need to as this behavior has proven to be confusing to some users: astral-sh/ruff-vscode#711

@MichaReiser MichaReiser force-pushed the micha/handle-configuration-errors branch from e443d6c to 7e039f8 Compare July 14, 2025 09:28
@MichaReiser MichaReiser force-pushed the micha/python-extension-environment branch from 0de50c6 to 2e35bfd Compare July 14, 2025 09:30
Base automatically changed from micha/python-extension-environment to main July 14, 2025 09:47
@MichaReiser MichaReiser force-pushed the micha/handle-configuration-errors branch from 7e039f8 to f2bba75 Compare July 14, 2025 09:58
@MichaReiser MichaReiser merged commit cb530a0 into main Jul 14, 2025
37 checks passed
@MichaReiser MichaReiser deleted the micha/handle-configuration-errors branch July 14, 2025 10:27
dcreager added a commit that referenced this pull request Jul 14, 2025
* dcreager/merge-arguments: (223 commits)
  fix docs
  Combine CallArguments and CallArgumentTypes
  [ty] Sync vendored typeshed stubs (#19334)
  [`refurb`] Make example error out-of-the-box (`FURB122`) (#19297)
  [refurb] Make example error out-of-the-box (FURB177) (#19309)
  [ty] ignore errors when reformatting codemodded typeshed (#19332)
  [ty] Provide docstrings for stdlib APIs when hovering over them in an IDE (#19311)
  [ty] Add virtual files to the only project database (#19322)
  Add t-string fixtures for rules that do not need to be modified (#19146)
  [ty] Remove `FileLookupError` (#19323)
  [ty] Fix handling of metaclasses in `object.<CURSOR>` completions
  [ty] Use an interval map for scopes by expression (#19025)
  [ty] List all `enum` members (#19283)
  [ty] Handle configuration errors in LSP more gracefully (#19262)
  [ty] Use python version and path from Python extension (#19012)
  [`pep8_naming`] Avoid false positives on standard library functions with uppercase names (`N802`) (#18907)
  Update Rust crate toml to 0.9.0 (#19320)
  [ty] Fix server version (#19284)
  Update NPM Development dependencies (#19319)
  Update taiki-e/install-action action to v2.56.13 (#19317)
  ...
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.

Gracefully handle invalid configurations during startup

2 participants