Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Formatter parentheses support for
IpyEscapeCommand
(#8207)
## 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
- Loading branch information
1 parent
c2ec5f0
commit dbd84c9
Showing
4 changed files
with
67 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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