ruff/crates
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
..
red_knot Eagerly validate search paths (#12783) 2024-08-12 07:46:59 +00:00
red_knot_python_semantic Add scope and definitions for comprehensions (#12748) 2024-08-13 07:00:33 +05:30
red_knot_server Consider VS Code cell metadata to determine valid code cells (#12864) 2024-08-13 22:09:56 +05:30
red_knot_wasm [red-knot] Add filename and source location for diagnostics (#12842) 2024-08-12 15:56:30 +00:00
red_knot_workspace [red-knot] Use Windows specific path separator in tests (#12847) 2024-08-12 22:26:59 +05:30
ruff Bump version to 0.5.7 (#12756) 2024-08-08 20:56:15 +05:30
ruff_benchmark Add scope and definitions for comprehensions (#12748) 2024-08-13 07:00:33 +05:30
ruff_cache Fix cache key collisions for paths with separators (#12159) 2024-07-03 07:36:46 -05:00
ruff_db Skip checking a file if it failed to read (#12755) 2024-08-12 07:26:37 +00:00
ruff_dev Drop deprecated `nursery` rule group (#10172) 2024-06-27 13:44:11 +02:00
ruff_diagnostics [Minor typo] Fix article in "an fix" (#12797) 2024-08-10 21:22:00 -04:00
ruff_formatter Upgrade to Rust 1.80 (#12586) 2024-07-30 19:18:08 +00:00
ruff_index [red-knot] small efficiency improvements and bugfixes to use-def map building (#12373) 2024-07-18 09:24:58 -07:00
ruff_linter Avoid treating `dataclasses.KW_ONLY` as typing-only (#12863) 2024-08-13 14:34:56 -04:00
ruff_macros Drop deprecated `nursery` rule group (#10172) 2024-06-27 13:44:11 +02:00
ruff_notebook Fallback to kernelspec to check if it's a Python notebook (#12875) 2024-08-14 12:36:09 +05:30
ruff_python_ast Implement `iter()`, `len()` and `is_empty()` for all display-literal AST nodes (#12807) 2024-08-12 10:39:28 +00:00
ruff_python_ast_integration_tests Rename `PreorderVisitor` to `SourceOrderVisitor` (#11798) 2024-06-07 17:01:58 +00:00
ruff_python_codegen Implement `iter()`, `len()` and `is_empty()` for all display-literal AST nodes (#12807) 2024-08-12 10:39:28 +00:00
ruff_python_formatter Implement `iter()`, `len()` and `is_empty()` for all display-literal AST nodes (#12807) 2024-08-12 10:39:28 +00:00
ruff_python_index Enable token-based rules on source with syntax errors (#11950) 2024-07-02 08:57:46 +00:00
ruff_python_literal Remove some unused `pub` functions (#11576) 2024-05-28 09:56:51 -04:00
ruff_python_parser Upgrade to Rust 1.80 (#12586) 2024-07-30 19:18:08 +00:00
ruff_python_resolver chore(deps): update rust crate insta to v1.38.0 (#10701) 2024-04-01 15:44:30 +00:00
ruff_python_semantic Implement `iter()`, `len()` and `is_empty()` for all display-literal AST nodes (#12807) 2024-08-12 10:39:28 +00:00
ruff_python_stdlib Add a new script to generate builtin module names (#12696) 2024-08-05 21:33:36 +01:00
ruff_python_trivia Mention that `Cursor` is based on rustc's implementation. (#12109) 2024-06-30 16:53:25 +01:00
ruff_python_trivia_integration_tests Build `CommentRanges` outside the parser (#11792) 2024-06-09 09:55:17 +00:00
ruff_server Consider VS Code cell metadata to determine valid code cells (#12864) 2024-08-13 22:09:56 +05:30
ruff_source_file red-knot: `source_text`, `line_index`, and `parsed_module` queries (#11822) 2024-06-13 07:37:02 +00:00
ruff_text_size Upgrade to Rust 1.79 (#11875) 2024-06-17 07:15:10 +01:00
ruff_wasm Bump version to 0.5.7 (#12756) 2024-08-08 20:56:15 +05:30
ruff_workspace Fix cache invalidation for nested pyproject.toml files (#12727) 2024-08-07 21:53:45 +02:00