Skip to content

Create ruff_notebook crate#7039

Merged
charliermarsh merged 2 commits intomainfrom
charlie/jupyter
Sep 1, 2023
Merged

Create ruff_notebook crate#7039
charliermarsh merged 2 commits intomainfrom
charlie/jupyter

Conversation

@charliermarsh
Copy link
Member

@charliermarsh charliermarsh commented Sep 1, 2023

Summary

This PR moves ruff/jupyter into its own ruff_notebook crate. Beyond the move itself, there were a few challenges:

  1. ruff_notebook relies on the source map abstraction. I've moved the source map into ruff_diagnostics, since it doesn't have any dependencies on its own and is used alongside diagnostics.
  2. ruff_notebook has a couple tests for end-to-end linting and autofixing. I had to leave these tests in ruff itself.
  3. We had code in ruff/jupyter that relied on Python lexing, in order to provide a more targeted error message in the event that a user saves a .py file with a .ipynb extension. I removed this in order to avoid a dependency on the parser, it felt like it wasn't worth retaining just for that dependency.

Test Plan

cargo test

@charliermarsh charliermarsh added the internal An internal refactor or improvement label Sep 1, 2023
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a better recommendation but moving source map to diagnostic feels a bit off because it isn't the only possible use case for source maps. For example, source maps can be used to move the IDE cursor to the right position after applying fixes. However, that requires extracting our fix infrastructure which is rather involved and even Fix is defined in Diagnostic

@github-actions
Copy link
Contributor

github-actions bot commented Sep 1, 2023

PR Check Results

Ecosystem

✅ ecosystem check detected no changes.

Copy link
Member

@dhruvmanila dhruvmanila left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was quick, thanks!

We might want to name it something along the lines of ruff_notebook as Jupyter is actually just a frontend while this crate would ideally handle notebooks in general (#6140)

@charliermarsh charliermarsh changed the title Create ruff_jupyter crate Create ruff_notebook crate Sep 1, 2023
@charliermarsh charliermarsh enabled auto-merge (squash) September 1, 2023 13:45
@charliermarsh charliermarsh merged commit afcd00d into main Sep 1, 2023
@charliermarsh charliermarsh deleted the charlie/jupyter branch September 1, 2023 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal An internal refactor or improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants