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.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add hidden
--extension
to override inference of source type from file extension #8373Add hidden
--extension
to override inference of source type from file extension #8373Changes from 10 commits
868eff6
c01a883
c05a21c
e6a4834
f4fe217
4284044
234b647
cf57f76
c307827
9a8fd17
b2c4caa
4fafe97
24d1957
e879d0c
50d7875
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for not noticing this in my first review 😓
How will this work if the cell contained IPython escape commands (
!pwd
,%matplotlib inline
)? The parser mode is tied up withPySourceType
. This mode is then used to allow the escape commands.ruff/crates/ruff_python_parser/src/lib.rs
Lines 325 to 332 in 2d5ce45
Now, if the cell contained escape commands and the override flag tells that this is a Python language (
--extension-override ipynb:python
), then it'll throw a syntax error.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jupyterlab-lsp
can replace notebook magics with equivalent python code in most cases, so in this use case these syntax errors are avoided (I think the code is here).Any python code affected by magic ends up in a string so doesn't get checked, for example with magics like
%time
and%%time
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for letting us know about that.
Coming from a public API perspective, this might still be a problem as, for example, if someone's trying to use it in a similar manner with an integration that doesn't perform those transformations, we'd throw an error.
I would love any other opinion on this. I'm fine with including the flag but if we include it in the config, then it's part of the public API which is where I'm unsure of.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW
jupyter nbconvert --to script
also seems to convert notebook magics to python in the same way.nbdev
has a routine callledscrub_magics
which removes magics altogether, though it seems to be optional.The docs could make it clear that
python
meanspython
without notebookisms. Maybe something like: