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

Create ruff_notebook crate #7039

Merged
merged 2 commits into from
Sep 1, 2023
Merged

Create ruff_notebook crate #7039

merged 2 commits into from
Sep 1, 2023

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

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

crates/ruff_cli/src/diagnostics.rs Show resolved Hide resolved
@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
16 checks passed
@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