[ty] Improve .toml support in the ty playground#23476
[ty] Improve .toml support in the ty playground#23476MichaReiser merged 3 commits intoastral-sh:mainfrom
.toml support in the ty playground#23476Conversation
|
Thanks for looking into this. The lack of TOML support in Monaco is the main reason the playground uses JSON for its configuration and it's a pity that Claude didn't manage to write a grammar for TOML. I'm not sure we should make this change for two reasons:
What I did in Ruff's playground was add support for pasting a TOML configuration (or copying it as TOML). Although I don't think it's a feature commonly used. Although I don't know how commonly this feature is used. |
Sorry, maybe I wasn't clear in PR description Claude wrote a grammar that appeared to work correctly in my testing but I wasn't sure about the first draft of this being: "Here's some AI code, I have manually tested it but don't have the background to self-review in the depth I would like, want to take on the maintenance burden for it? 😉" Here is a Gist of it: https://gist.github.com/sinon/d3840c6cba19a5d744c9b4a4f5a23dc6 |
|
I'm fine with an AI generated-grammar. I'd appreciate it if you read through it to double-check that it makes sense overall. This would bring TOML support close to JSON, without supporting completions. But adding completions is rather involved because it requires schema parsing etc. After second consideration. I'd be fine merging this PR with an updated TOML grammar but I still think that JSON should be the default because it provides a better experience overall. |
* main: [ty] Filter out unsatisfiable inference attempts during generic call narrowing (#24025) [ty] Avoid inferring intersection types for call arguments (#23933) [ty] Pin mypy_primer in `setup_primer_project.py` (#24020) [`pycodestyle`] Recognize `pyrefly:` as a pragma comment (`E501`) (#24019) Add company AI policy to contributing guide (#24021) [ty] Remove the mypy_primer CI workflow (#24016) Update prek dependencies (#23980) [ty] Smarter semantic token classification for attribute access on union type (#23841) [ty] ecosystem-analyzer: Inline diffs and panic messages (#24015) [ty] Improve `.toml` support in the ty playground (#23476) PEP 639 license information (#19661)


Closes: astral-sh/ty#2671
Summary
Adds clearer
tomlsupport to the playground editor. This makes replicating issues in playground where users have a pre-existingty.tomlorpyproject.tomlmore straight forward. Note: ty-wasm already detected and worked with these files in the playground and respected these settings files without any additional change, so this change is more focussed on the visual fidelity of the experience.Consists of two main changes:
material-extensions/vscode-material-icon-themeand including attribution)Add an override that whenTOML language support microsoft/monaco-editor#2798.tomlextension is encountered therubysyntax highlight is set. There is currently no in-built Monarch grammar or off the shelf 3rd party one that can be added as a dependency. I did have Claude have a bash at generating the grammar it produced something complex and probably correct but for now I opted for setting therubygrammar as this gives the basic syntax highlighting needed for most common uses in ty config, without the potential maintenance overhead. This is recommended on the toml feature request issue as the best fallback:.tomlsupport in the ty playground #23476 (comment) for testing infoTest Plan
npm start --workspace ty-playgroundty.jsonty.tomlty.tomlcreate apyproject.tomlrepeat the verification steps fromty.toml