Skip to content

Conversation

@ntBre
Copy link
Contributor

@ntBre ntBre commented Aug 8, 2025

Summary

This is a follow-up to #19415 (comment) to remove some unused code. As Micha noticed, GroupedEmitter::with_show_source was only used in local unit tests1 and was safe to remove. This allowed deleting MessageCodeFrame and a lot more helper code previously shared with the full output format.

I also moved some other code from text.rs and message/mod.rs into grouped.rs that is now only used for the grouped format. With a little refactoring of the concise rendering logic in ruff_db, we could probably remove RuleCodeAndBody too. The only difference I see from the concise output is whether we print the filename next to the row and column or not:

> ruff check --output-format concise
try.py:1:8: F401 [*] `math` imported but unused
> ruff check --output-format grouped
try.py:
  1:8 F401 [*] `math` imported but unused

But I didn't try to do that here.

Test Plan

Existing tests, with the source code no longer displayed. I also deleted one test, as it was now a duplicate of the default test.

Footnotes

  1. "Local unit tests" as opposed to all of our linter snapshot tests, as is the case for TextEmitter::with_show_fix_diff. We also want to expose that to users eventually (https://github.com/astral-sh/ruff/issues/7352), which I don't believe is the case for the grouped format.

@github-actions
Copy link
Contributor

github-actions bot commented Aug 8, 2025

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Formatter (stable)

✅ ecosystem check detected no format changes.

Formatter (preview)

✅ ecosystem check detected no format changes.

@ntBre ntBre changed the title Brent/cleanup unused code Clean up unused rendering code in ruff_linter Aug 8, 2025
@ntBre ntBre added the internal An internal refactor or improvement label Aug 8, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Aug 8, 2025

Diagnostic diff on typing conformance tests

No changes detected when running ty on typing conformance tests ✅

@github-actions
Copy link
Contributor

github-actions bot commented Aug 8, 2025

mypy_primer results

No ecosystem changes detected ✅
No memory usage changes detected ✅

@ntBre ntBre marked this pull request as ready for review August 8, 2025 18:57
@ntBre ntBre requested a review from MichaReiser August 8, 2025 18:57
Copy link
Member

@MichaReiser MichaReiser left a comment

Choose a reason for hiding this comment

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

Nice

@ntBre ntBre merged commit 8230b79 into main Aug 9, 2025
38 checks passed
@ntBre ntBre deleted the brent/cleanup-unused-code branch August 9, 2025 18:20
dcreager added a commit that referenced this pull request Aug 11, 2025
* main: (31 commits)
  Add AIR301 rule (#17707)
  Avoid underflow in default ranges before a BOM (#19839)
  Update actions/download-artifact digest to de96f46 (#19852)
  Update docker/login-action action to v3.5.0 (#19860)
  Update rui314/setup-mold digest to 7344740 (#19853)
  Update cargo-bins/cargo-binstall action to v1.14.4 (#19855)
  Update actions/cache action to v4.2.4 (#19854)
  Update Rust crate hashbrown to v0.15.5 (#19858)
  Update Rust crate camino to v1.1.11 (#19857)
  Update Rust crate proc-macro2 to v1.0.96 (#19859)
  Update dependency ruff to v0.12.8 (#19856)
  SIM905: Fix handling of U+001C..U+001F whitespace (#19849)
  RUF064: offer a safe fix for multi-digit zeros (#19847)
  Clean up unused rendering code in `ruff_linter` (#19832)
  [ty] Add Salsa caching to `TupleType::to_class_type` (#19840)
  [ty] Handle cycles when finding implicit attributes (#19833)
  [ty] fix goto-definition on imports (#19834)
  [ty] Implement stdlib stub mapping (#19529)
  [`flake8-comprehensions`] Fix false positive for `C420` with attribute, subscript, or slice assignment targets (#19513)
  [ty] Implement module-level `__getattr__` support (#19791)
  ...
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