ruff/.github/workflows
Brent Westbrook 4daf59e5e7
Move concise diagnostic rendering to `ruff_db` (#19398)
## Summary

This PR moves most of the work of rendering concise diagnostics in Ruff
into `ruff_db`, where the code is shared with ty. To accomplish this
without breaking backwards compatibility in Ruff, there are two main
changes on the `ruff_db`/ty side:
- Added the logic from Ruff for remapping notebook line numbers to cells
- Reordered the fields in the diagnostic to match Ruff and rustc
  ```text
  # old
error[invalid-assignment] try.py:3:1: Object of type `Literal[1]` is not
assignable to `str`
  # new
try.py:3:1: error[invalid-assignment]: Object of type `Literal[1]` is
not assignable to `str`
  ```

I don't think the notebook change failed any tests on its own, and only
a handful of snaphots changed in ty after reordering the fields, but
this will obviously affect any other uses of the concise format, outside
of tests, too.

The other big change should only affect Ruff:

- Added three new `DisplayDiagnosticConfig` options
Micha and I hoped that we could get by with one option
(`hide_severity`), but Ruff also toggles `show_fix_status` itself,
independently (there are cases where we want neither severity nor the
fix status), and during the implementation I realized we also needed
access to an `Applicability`. The main goal here is to suppress the
severity (`error` above) because ruff only uses the `error` severity and
to use the secondary/noqa code instead of the line name
(`invalid-assignment` above).
  ```text
  # ty - same as "new" above
try.py:3:1: error[invalid-assignment]: Object of type `Literal[1]` is
not assignable to `str`
  # ruff
try.py:3:1: RUF123 [*] Object of type `Literal[1]` is not assignable to
`str`
  ```

This part of the concise diagnostic is actually shared with the `full`
output format in Ruff, but with the settings above, there are no
snapshot changes to either format.

## Test Plan

Existing tests with the handful of updates mentioned above, as well as
some new tests in the `concise` module.

Also this PR. Swapping the fields might have broken mypy_primer, unless
it occasionally times out on its own.

I also ran this script in the root of my Ruff checkout, which also has
CPython in it:

```shell
flags=(--isolated --no-cache --no-respect-gitignore --output-format concise .)
diff <(target/release/ruff check ${flags[@]} 2> /dev/null) \
     <(ruff check ${flags[@]} 2> /dev/null)
```

This yielded an expected diff due to some t-string error changes on main
since 0.12.4:
```diff
33622c33622
< crates/ruff_python_parser/resources/inline/err/f_string_lambda_without_parentheses.py:1:15: SyntaxError: Expected an element of or the end of the f-string
---
> crates/ruff_python_parser/resources/inline/err/f_string_lambda_without_parentheses.py:1:15: SyntaxError: Expected an f-string or t-string element or the end of the f-string or t-string
33742c33742
< crates/ruff_python_parser/resources/inline/err/implicitly_concatenated_unterminated_string_multiline.py:4:1: SyntaxError: Expected an element of or the end of the f-string
---
> crates/ruff_python_parser/resources/inline/err/implicitly_concatenated_unterminated_string_multiline.py:4:1: SyntaxError: Expected an f-string or t-string element or the end of the f-string or t-string
34131c34131
< crates/ruff_python_parser/resources/inline/err/t_string_lambda_without_parentheses.py:2:15: SyntaxError: Expected an element of or the end of the t-string
---
> crates/ruff_python_parser/resources/inline/err/t_string_lambda_without_parentheses.py:2:15: SyntaxError: Expected an f-string or t-string element or the end of the f-string or t-string
```

So modulo color, the results are identical on 38,186 errors in our test
suite and CPython 3.10.

---------

Co-authored-by: David Peter <mail@david-peter.de>
2025-07-23 11:43:32 -04:00
..
build-binaries.yml Update PyO3/maturin-action action to v1.49.3 (#19033) 2025-06-30 13:08:04 +05:30
build-docker.yml Update docker/setup-buildx-action action to v3.11.1 (#18881) 2025-06-23 08:06:43 +02:00
ci.yaml Run MD tests for Markdown-only changes (#19479) 2025-07-22 11:29:07 +02:00
daily_fuzz.yaml Update rui314/setup-mold digest to 702b190 (#19441) 2025-07-21 08:31:47 +02:00
mypy_primer.yaml [ty] Do not run `mypy_primer.yaml` when all changed files are Markdown files (#19244) 2025-07-09 19:40:43 +01:00
mypy_primer_comment.yaml [ty] Add separate CI job for memory usage stats (#19134) 2025-07-07 12:17:02 -04:00
notify-dependents.yml Update actions/github-script action to v7.0.1 (#17072) 2025-03-31 09:24:38 +02:00
pr-comment.yaml Update peter-evans/find-comment action to v3.1.0 (#18177) 2025-05-19 08:10:14 +02:00
publish-docs.yml Update Swatinem/rust-cache action to v2.8.0 (#19168) 2025-07-07 08:50:29 +05:30
publish-playground.yml Update actions/setup-node action to v4.4.0 (#17514) 2025-04-22 09:18:13 +02:00
publish-pypi.yml Update astral-sh/setup-uv action to v6.3.1 (#19031) 2025-06-30 13:06:39 +05:30
publish-ty-playground.yml Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
publish-wasm.yml Update actions/setup-node action to v4.4.0 (#17514) 2025-04-22 09:18:13 +02:00
release.yml Update actions/checkout digest to 09d2aca (#18576) 2025-06-09 08:08:02 +02:00
sync_typeshed.yaml [ty] bump docstring-adder pin (#19458) 2025-07-21 13:38:40 +01:00
ty-ecosystem-analyzer.yaml Move concise diagnostic rendering to `ruff_db` (#19398) 2025-07-23 11:43:32 -04:00
ty-ecosystem-analyzer_comment.yaml [ty] Ecosystem analyzer PR comment workflow (#19237) 2025-07-09 18:02:05 +02:00
ty-ecosystem-report.yaml Move concise diagnostic rendering to `ruff_db` (#19398) 2025-07-23 11:43:32 -04:00