Consider VS Code cell metadata to determine valid code cells#12864
Merged
dhruvmanila merged 2 commits intomainfrom Aug 13, 2024
Merged
Consider VS Code cell metadata to determine valid code cells#12864dhruvmanila merged 2 commits intomainfrom
dhruvmanila merged 2 commits intomainfrom
Conversation
8e977dd to
11c222c
Compare
MichaReiser
approved these changes
Aug 13, 2024
Member
MichaReiser
left a comment
There was a problem hiding this comment.
Awesome, thank you.
I think it would be good to add a round-trip test case with additional CellMetadata.
CodSpeed Performance ReportMerging #12864 will degrade performances by 4.09%Comparing Summary
Benchmarks breakdown
|
Contributor
|
Member
Author
|
Added a simple roundtrip test case with additional cell metadata. I also tested it using |
1 task
dhruvmanila
added a commit
that referenced
this pull request
Aug 14, 2024
## Summary Follow-up to #12864, we don't need to exclude these notebooks anymore. ## Test plan - [x] Make sure that ecosystem checks are green.
dhruvmanila
added a commit
to astral-sh/ruff-lsp
that referenced
this pull request
Sep 3, 2024
## Summary Related to astral-sh/ruff#12864, the cell metadata is actually a required field. We got away with it previously because Ruff used `Value`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds support for VS Code specific cell metadata to consider when collecting valid code cells.
For context, Ruff only runs on valid code cells. These are the code cells that doesn't contain cell magics. Previously, Ruff only used the notebook's metadata to determine whether it's a Python notebook. But, in VS Code, a notebook's preferred language might be Python but it could still contain code cells for other languages. This can be determined with the
metadata.vscode.languageIdfield.References:
This brings us one step closer to fixing #12281.
Test Plan
Add test cases for
is_valid_python_code_celland an integration test case which showcase running it end to end. The test notebook contains a JavaScript code cell and a Python code cell.