Skip to content

Red Knot Playground #12681

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 18, 2025
Merged

Red Knot Playground #12681

merged 1 commit into from
Mar 18, 2025

Conversation

MichaReiser
Copy link
Member

@MichaReiser MichaReiser commented Aug 5, 2024

Summary

This PR adds a playground for Red Knot

Screencast.from.2024-08-14.10-33-54.webm

Sharing does work 😆 I just forgot to start wrangler.

It supports:

  • Multiple files
  • Showing the AST
  • Showing the tokens
  • Sharing
  • Persistence to local storage

Future extensions:

  • Configuration support: The pyproject.toml would just be another file.
  • Showing type information on hover

Blockers

Salsa uses catch_unwind to break cycles, which Red Knot uses extensively when inferring types in the standard library.
However, WASM (at least wasm32-unknown-unknown) doesn't support catch_unwind today, so the playground always crashes when the type inference encounters a cycle.

I created a discussion in the salsa zulip to see if it would be possible to not use catch unwind to break cycles.

Rust tracking issue for WASM catch unwind support

I tried to build the WASM with the nightly compiler option but ran into problems because wasm-bindgen doesn't support WASM-exceptions. We could try to write the binding code by hand.

Another alternative is to use wasm32-unknown-emscripten but it's rather painful to build

@MichaReiser MichaReiser added the ty Multi-file analysis & type inference label Aug 10, 2024
@MichaReiser MichaReiser force-pushed the red-knot-playground branch 4 times, most recently from 1fa1770 to f2582fd Compare August 11, 2024 15:04
Copy link

codspeed-hq bot commented Aug 11, 2024

CodSpeed Performance Report

Merging #12681 will not alter performance

Comparing red-knot-playground (2f7c8e3) with main (dcf31c9)

Summary

✅ 32 untouched benchmarks

Copy link
Contributor

github-actions bot commented Aug 11, 2024

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Formatter (stable)

✅ ecosystem check detected no format changes.

Formatter (preview)

✅ ecosystem check detected no format changes.

@MichaReiser MichaReiser force-pushed the red-knot-playground branch 3 times, most recently from 4d4c5c8 to faf316b Compare August 14, 2024 08:22
@MichaReiser MichaReiser changed the title [WIP] Red Knot Playground Red Knot Playground Aug 14, 2024
@TomerBin
Copy link
Contributor

TomerBin commented Oct 1, 2024

Hey! Any updates about this? Do we have any sort of playground for red knot at the moment?

@MichaReiser
Copy link
Member Author

No, there's no update. This is blocked on adding WASM support to salsa. See https://salsa.zulipchat.com/#narrow/stream/333573-Contributing-to-Salsa/topic/WASM.20support

@MichaReiser
Copy link
Member Author

I plan to pick this up again on the side. It's now unblocked as we use salsa's new fixpoint infrastructure that doesn't rely on panics to resolve cycles.

@MichaReiser MichaReiser force-pushed the red-knot-playground branch 2 times, most recently from c5e07db to f75f360 Compare March 18, 2025 10:32
@MichaReiser MichaReiser added the playground A playground-specific issue label Mar 18, 2025
@MichaReiser

This comment was marked as resolved.

@MichaReiser MichaReiser force-pushed the red-knot-playground branch 4 times, most recently from 4be75de to c5b9398 Compare March 18, 2025 14:24
Copy link
Contributor

github-actions bot commented Mar 18, 2025

mypy_primer results

No ecosystem changes detected ✅

@MichaReiser MichaReiser force-pushed the red-knot-playground branch from c5b9398 to 370fa9e Compare March 18, 2025 16:00
@MichaReiser MichaReiser force-pushed the red-knot-playground branch from 370fa9e to 2f7c8e3 Compare March 18, 2025 16:10
@MichaReiser MichaReiser marked this pull request as ready for review March 18, 2025 16:16
@MichaReiser MichaReiser requested a review from carljm as a code owner March 18, 2025 16:16
@MichaReiser MichaReiser merged commit c027979 into main Mar 18, 2025
23 checks passed
@MichaReiser MichaReiser deleted the red-knot-playground branch March 18, 2025 16:17
dcreager added a commit that referenced this pull request Mar 18, 2025
* main:
  [playground] Avoid concurrent deployments (#16834)
  [red-knot] Infer `lambda` return type as `Unknown` (#16695)
  [red-knot] Move `name` field on parameter kind (#16830)
  [red-knot] Emit errors for more AST nodes that are invalid (or only valid in specific contexts) in type expressions (#16822)
  [playground] Use cursor for clickable elements (#16833)
  [red-knot] Deploy playground on main (#16832)
  Red Knot Playground (#12681)
  [syntax-errors] PEP 701 f-strings before Python 3.12 (#16543)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
playground A playground-specific issue ty Multi-file analysis & type inference
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants