-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Failed to format notebook: source contains syntax errors: ParseError #8204
Comments
Can you try adding the notebook extensions to [tool.ruff]
extend-include = ["*.ipynb"] |
|
Interesting. @dhruvmanila any ideas? Could it be that we don't correctly set the parsing mode? |
Yeah, that's correct. Let me send in a patch quickly. |
## Summary This PR removes the `todo!()` around `IpyEscapeCommand` in the formatter. The `NeedsParentheses` trait needs to be implemented which always return `Never`. The reason being that if an escape command is parenthesized, then that's not parsed as an escape command. IOW, the parentheses shouldn't be present around an escape command. In the similar way, the `CanSkipOptionalParenthesesVisitor` will skip this node. ## Test Plan Updated the `unformatted.ipynb` fixture with new cells containing IPython escape commands and the corresponding snapshot was verified. Also, tested it out in a few open source repositories containing notebooks (`openai/openai-cookbook`, `huggingface/notebooks`). #### New cells in `unformatted.ipynb` **Cell 2** ```markdown A markdown cell ``` **Cell 3** ```python def some_function(foo, bar): pass %matplotlib inline ``` **Cell 4** ```python foo = %pwd def some_function(foo,bar,): foo = %pwd print(foo ) ``` fixes: #8204
Thanks for opening this issue! It's fixed and will be available in the next release. |
@dhruvmanila Thanks for fixing this! I'm curious when the the next release will be available. |
I can probably cut a release tomorrow. |
Hi,
I tried the new ruff formatter on my notebooks through a pre-commit config:
But I get these errors:
Here is the pyproject.toml:
And the notebooks: https://github.com/kili-technology/kili-python-sdk/tree/main/recipes
Thanks a lot!
The text was updated successfully, but these errors were encountered: