diff --git a/crates/red_knot_wasm/src/lib.rs b/crates/red_knot_wasm/src/lib.rs index ba1dc01bea..a28b41f2fd 100644 --- a/crates/red_knot_wasm/src/lib.rs +++ b/crates/red_knot_wasm/src/lib.rs @@ -214,6 +214,10 @@ impl FileHandle { pub fn js_to_string(&self) -> String { format!("file(id: {:?}, path: {})", self.file, self.path) } + + pub fn path(&self) -> String { + self.path.to_string() + } } #[wasm_bindgen] diff --git a/playground/knot/src/Editor/Chrome.tsx b/playground/knot/src/Editor/Chrome.tsx index ebfadade91..c55d9787b3 100644 --- a/playground/knot/src/Editor/Chrome.tsx +++ b/playground/knot/src/Editor/Chrome.tsx @@ -220,7 +220,9 @@ function useCheckResult( const currentHandle = files.handles[files.selected]; - if (currentHandle == null) { + const extension = + currentHandle?.path()?.toLowerCase().split(".").pop() ?? ""; + if (currentHandle == null || !["py", "pyi", "pyw"].includes(extension)) { return { diagnostics: [], error: null,