ruff/crates/ruff_notebook/resources/test/fixtures/jupyter
Dhruv Manilawala 2520ebb145
Fallback to kernelspec to check if it's a Python notebook (#12875)
## Summary

This PR adds a fallback logic for `is_python_notebook` to check the
`kernelspec.language` field.

Reference implementation in VS Code:
1c31e75898/extensions/ipynb/src/deserializers.ts (L20-L22)

It's also required for the kernel to provide the `language` they're
implementing based on
https://jupyter-client.readthedocs.io/en/stable/kernels.html#kernel-specs
reference although that's for the `kernel.json` file but is also
included in the notebook metadata.

Closes: #12281

## Test Plan

Add a test case for `is_python_notebook` and include the test notebook
for round trip validation.

The test notebook contains two cells, one is JavaScript (denoted via the
`vscode.languageId` metadata) and the other is Python (no metadata). The
notebook metadata only contains `kernelspec` and the `language_info` is
absent.

I also verified that this is a valid notebook by opening it in Jupyter
Lab, VS Code and using `nbformat` validator.
2024-08-14 12:36:09 +05:30
..
cell Consider VS Code cell metadata to determine valid code cells (#12864) 2024-08-13 22:09:56 +05:30
add_missing_cell_id.ipynb Create ruff_notebook crate (#7039) 2023-09-01 13:56:44 +00:00
after_fix.ipynb Create ruff_notebook crate (#7039) 2023-09-01 13:56:44 +00:00
before_fix.ipynb Create ruff_notebook crate (#7039) 2023-09-01 13:56:44 +00:00
invalid_extension.ipynb Create ruff_notebook crate (#7039) 2023-09-01 13:56:44 +00:00
ipy_escape_command.ipynb Allow transparent cell magics (#8911) 2023-12-07 14:15:43 -06:00
ipy_escape_command_expected.ipynb Allow transparent cell magics (#8911) 2023-12-07 14:15:43 -06:00
isort.ipynb Create ruff_notebook crate (#7039) 2023-09-01 13:56:44 +00:00
isort_expected.ipynb Create ruff_notebook crate (#7039) 2023-09-01 13:56:44 +00:00
kernelspec_language.ipynb Fallback to kernelspec to check if it's a Python notebook (#12875) 2024-08-14 12:36:09 +05:30
no_cell_id.ipynb Create ruff_notebook crate (#7039) 2023-09-01 13:56:44 +00:00
no_trailing_newline.ipynb Create ruff_notebook crate (#7039) 2023-09-01 13:56:44 +00:00
not_json.ipynb Create ruff_notebook crate (#7039) 2023-09-01 13:56:44 +00:00
R.ipynb Create ruff_notebook crate (#7039) 2023-09-01 13:56:44 +00:00
undefined_name.ipynb Detect automagic-like assignments in notebooks (#9653) 2024-01-29 12:55:44 +00:00
unused_variable.ipynb Create ruff_notebook crate (#7039) 2023-09-01 13:56:44 +00:00
unused_variable_expected.ipynb Create ruff_notebook crate (#7039) 2023-09-01 13:56:44 +00:00
valid.ipynb Create ruff_notebook crate (#7039) 2023-09-01 13:56:44 +00:00
vscode_language_id.ipynb Consider VS Code cell metadata to determine valid code cells (#12864) 2024-08-13 22:09:56 +05:30
vscode_language_id_expected.ipynb Consider VS Code cell metadata to determine valid code cells (#12864) 2024-08-13 22:09:56 +05:30
wrong_schema.ipynb Create ruff_notebook crate (#7039) 2023-09-01 13:56:44 +00:00