Skip to content
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

Test: notebook.format Code Action #213608

Closed
3 tasks done
Yoyokrazy opened this issue May 28, 2024 · 2 comments
Closed
3 tasks done

Test: notebook.format Code Action #213608

Yoyokrazy opened this issue May 28, 2024 · 2 comments

Comments

@Yoyokrazy
Copy link
Contributor

Yoyokrazy commented May 28, 2024

Refs: #212381

Complexity: 5

author: @Yoyokrazy

Create Issue


Summary:

Support for notebook scoped formatting via code actions is now supported with the Code Action Kind notebook.format.xyz. This is to enable formatters to provide richer edits that are able to leverage the NotebookEdit type, allowing them to add, delete, and shift cells, in addition to all of the standard textual edits within a cell.

The intended user story for this feature is as follows: The user will install an extension that provides a notebook.format.xyz code action. To the user, they shouldn't need to know anything about the implementation details, or about the fact that it will provide a code action, rather than document formatting edits. The inner workings of the format code action should be controlled via the extension settings. The user should be able to control the behavior of this feature from the settings menu by turning on or off format on save or setting a different default formatter.

Steps to test:

This section is going to be flexible, allowing testers to either develop and test via their own extension, or by tweaking an extension sample I have already created here. You can trigger this formatting code action by enabling the setting notebook.formatOnSave.enabled. You can also define this in notebook.codeActionsOnSave and although this is not the intended use, it would be good to do this to check for any notebook-breaking behaviors.

Things to look out for:

  • Read through the referenced issue to get an idea of some of the best practices for defining code action providers, and some of the common issues that people run into. If you can try to poke holes in this, great. This is currently in development and in talks with ruff and black, so the goal is to get feedback so this better suits everyone's needs.
  • If you have two extensions providing a notebook.format.xyz code action, you should receive a warning, and be prompted to update the notebook.defaultFormatter setting. This will have you set the fully qualified extension id of the code action provider that will handle formatting
    • Make sure that the correct code action is being applied as well
@bpasero
Copy link
Member

bpasero commented May 28, 2024

This is quite powerful and seems to work great. I am not a target audience so I just came up with an action provider that sorts cells by alphabet based on content. If you want more honest feedback I would really recommend to ping stakeholders in that referenced issue to try it out as well.

For the future, if you want me to test more specific areas, please spell that out explicitly. I would not ask testers to go read through an issue to find things to test, that will very likely result in testers doing less compared to spelling it out explicitly in the test plan.

@Tyriar
Copy link
Member

Tyriar commented May 28, 2024

Also if there are people on the Python/Jupyter team that are actually use the API, this is a good excuse to both test and start implementing it which should result in great feedback.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants