astral-sh / ruff-vscode

A Visual Studio Code extension with support for the Ruff linter.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Expected a Jupyter Notebook error when opening a notebook

simonschmidt opened this issue · comments

When opening a notebook there's a glitch where on line 1 of each cell I get the error:

SyntaxError: Expected a Jupyter Notebook, which must be internally stored as JSON, but this file isn't valid JSON: expected ident at line 1 column 2RuffE999

The error goes away when I save the notebook but reappears if close and reopen the notebook.

notebok_err

ruff: 0.2.2
vscode: 1.87.0
ruff vscode extension: v2024.12.0
jupyter vscode extension: v2024.2.0
python: 3.12


Any notebook will do, but for example, with this saved as hello_world.ipynb:

{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from __future__ import annotations\n",
    "\n",
    "print(\"Hello World\")"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}

I don't know anything about vscode internals, but syntax highlighting issues started at the same time. May or may not be related: microsoft/pylance-release#5543

Edit: Downgrading to vscode 1.86.2 made this "Expected a Jupyter Notebook" error go away as well

Yes, seems related, also seeing both issues and downgrading to https://code.visualstudio.com/updates/v1_86 fixes it.

I've been getting the same error on all non-saved notebooks. E.g., if I ctrl+s the error goes away until I do an edit.

Jupyter vs code extension v2024.2.0
Pylance vs code extension v2024.2.3
Ruff vs code extension v2024.14.0
VS Code version 1.8.7.0

Downgrading to 1.8.6 fixes the problem.

I'm running VS Code on Windows 10 against Ubuntu-20.4 via WSL

Ugh, I'm unable to reproduce this on my mac machine. Can anyone provide steps to reproduce this?

VS Code version:

Version: 1.87.0
Commit: 019f4d1419fbc8219a181fab7892ebccf7ee29a2
OS: Darwin arm64 23.1.0

Ruff VS Code extension version: v2024.14.0
Pylance VS Code extension version: v2024.2.3

As per the linked issue, I think it's a bug on Windows only? @simonschmidt @olsgaard can you provide what OS are you seeing this on?

The issue has been fixed on the insider version which I guess would be released in stable in a few weeks. Until then, can you try downgrading your VS Code version to 1.86.*?

I'm on Linux (Fedora) I'm not sure but I think the windows user are using WSL.

I tried vscode insiders v1.88.0 which indeed has resolved the issue, I'll close this issue as I don't think there's anything left to do but wait for next stable release

@dhruvmanila I've updated my comment with more details.

I'll wait for the next stable VS Code release and see what happens. Thank you for looking into this.