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

Add RDJson support #11682

Merged
merged 7 commits into from
Jun 2, 2024
Merged

Add RDJson support #11682

merged 7 commits into from
Jun 2, 2024

Conversation

tobb10001
Copy link
Contributor

Summary

Implement support for RDJson output for ruff check, as requested in #8655.

Test Plan

Tested using a snapshot test. Same approach as for e.g. the JSON output formatter.

Additional info

I tried to keep the implementation close to the JSON implementation.

I had to deviate a bit to make the suggestions key work: If there are no suggestions, then setting suggestions to null is invalid according to the JSONSchema. Therefore, I opted for a slightly more complex implementation, that skips the suggestions key entirely if there are no fixes available for the given diagnostic. Maybe it would have been easier to set "suggestions": [], but I ended up doing it this way.

I didn't consider notebooks, as I think that RDJson doesn't work with notebooks. This should be confirmed, and if so, there should be some form of warning or error emitted when trying to output diagnostics for a notebook.

I also didn't consider ruff format, as this comment: #8655 (comment) suggests that that wouldn't be compatible.

I'm new to Rust, any feedback is appreciated. 🙂 I implemented this in order to have a productive rainy saturday afternoon, I'm not knowledgeable about RDJson beyond the sources linked in the issue.

Copy link
Contributor

github-actions bot commented Jun 1, 2024

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Copy link
Member

@charliermarsh charliermarsh left a comment

Choose a reason for hiding this comment

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

Nice, this looks good! Thank you!

@charliermarsh charliermarsh enabled auto-merge (squash) June 2, 2024 17:57
@charliermarsh charliermarsh added the configuration Related to settings and configuration label Jun 2, 2024
@charliermarsh charliermarsh changed the title Add RDJson support. Add RDJson support Jun 2, 2024
@charliermarsh charliermarsh merged commit 0ea2519 into astral-sh:main Jun 2, 2024
17 checks passed
carljm added a commit that referenced this pull request Jun 3, 2024
* main: (25 commits)
  Isolate non-breaking whitespace indentation test case (#11721)
  Generator should add a newline before type statement (#11720)
  Remove less used parser dependencies (#11718)
  Use string expression for parsing type annotation (#11717)
  Re-order lexer methods (#11716)
  Maintain synchronicity between the lexer and the parser (#11457)
  Update NPM Development dependencies (#11713)
  Update pre-commit dependencies (#11712)
  Update cloudflare/wrangler-action action to v3.6.1 (#11709)
  Update dependency monaco-editor to ^0.49.0 (#11710)
  Update Rust crate tracing-tree to v0.3.1 (#11703)
  Update Rust crate libcst to v1.4.0 (#11707)
  Update Rust crate itertools to 0.13.0 (#11706)
  Update Rust crate insta to v1.39.0 (#11705)
  Update Rust crate proc-macro2 to v1.0.85 (#11700)
  Update Rust crate toml to v0.8.13 (#11702)
  Update Rust crate strum_macros to v0.26.3 (#11701)
  Update UP035 for Python 3.13 and the latest version of typing_extensions (#11693)
  Add RDJson support. (#11682)
  [`pyupgrade`] Write empty string in lieu of panic (#11696)
  ...
carljm added a commit that referenced this pull request Jun 3, 2024
* cjm/cfg1: (26 commits)
  review comments
  Isolate non-breaking whitespace indentation test case (#11721)
  Generator should add a newline before type statement (#11720)
  Remove less used parser dependencies (#11718)
  Use string expression for parsing type annotation (#11717)
  Re-order lexer methods (#11716)
  Maintain synchronicity between the lexer and the parser (#11457)
  Update NPM Development dependencies (#11713)
  Update pre-commit dependencies (#11712)
  Update cloudflare/wrangler-action action to v3.6.1 (#11709)
  Update dependency monaco-editor to ^0.49.0 (#11710)
  Update Rust crate tracing-tree to v0.3.1 (#11703)
  Update Rust crate libcst to v1.4.0 (#11707)
  Update Rust crate itertools to 0.13.0 (#11706)
  Update Rust crate insta to v1.39.0 (#11705)
  Update Rust crate proc-macro2 to v1.0.85 (#11700)
  Update Rust crate toml to v0.8.13 (#11702)
  Update Rust crate strum_macros to v0.26.3 (#11701)
  Update UP035 for Python 3.13 and the latest version of typing_extensions (#11693)
  Add RDJson support. (#11682)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
configuration Related to settings and configuration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants