Conversation
Contributor
|
ntBre
commented
Sep 10, 2025
Comment on lines
+47
to
+51
| ",line={row},col={column},endLine={end_row},endColumn={end_column}::", | ||
| row = start_location.line, | ||
| column = start_location.column, | ||
| end_row = end_location.line, | ||
| end_column = end_location.column, |
Contributor
Author
There was a problem hiding this comment.
I think we could omit these entirely if there's no range, based on the docs, but I stuck with unwrap_or_default for now since that's what we were already doing for notebooks.
this prepares to move the code to `ruff_db` by using a `&dyn FileResolver` instead of the `EmitterContext` directly and by handling the cases where a span or range is missing. I think this also fixes a latent bug where we were only falling back on a default `LineColumn` for notebooks for the start location. `end_location` was used directly without respecting the `is_notebook` check. note that the one remaining `unwrap` call will disappear after moving the code to `ruff_db`. the `UnifiedFile` method we need is still private
this is the one piece of the refactor we couldn't do in the first commit, just because `diagnostic_source` is private. it probably doesn't have to be private, but it also hasn't needed to be public once we finish moving each output format over
See the example error message in the Github docs: <https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-commands#setting-an-error-message> ``` ::error file={name},line={line},endLine={endLine},title={title}::{message} ``` even if we don't have `file` or `line`, we still need the `::` before `message`.
BurntSushi
approved these changes
Sep 11, 2025
Member
BurntSushi
left a comment
There was a problem hiding this comment.
Nice! The commit breakdown was perfect, thank you!
I like the unwrap/expect removals. :-)
ntBre
added a commit
that referenced
this pull request
Sep 17, 2025
## Summary This PR wires up the GitHub output format moved to `ruff_db` in #20320 to the ty CLI. It's a bit smaller than the GitLab version (#20155) because some of the helpers were already in place, but I did factor out a few `DisplayDiagnosticConfig` constructor calls in Ruff. I also exposed the `GithubRenderer` and a wrapper `DisplayGithubDiagnostics` type because we needed a way to configure the program name displayed in the GitHub diagnostics. This was previously hard-coded to `Ruff`: <img width="675" height="247" alt="image" src="https://github.com/user-attachments/assets/592da860-d2f5-4abd-bc5a-66071d742509" /> Another option would be to drop the program name in the output format, but I think it can be helpful in workflows with multiple programs emitting annotations (such as Ruff and ty!) ## Test Plan New CLI test, and a manual test with `--config 'terminal.output-format = "github"'`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This is the GitHub analog to #20117. This PR prepares to add a GitHub output format to ty by moving the implementation from
ruff_lintertoruff_db. Hopefully this one is a bit easier to review commit-by-commit. Almost all of the refactoring this time is in the first commit, then the second commit adds the newOutputFormatvariant and moves the file intoruff_db. The third commit is just a small touch up to use a private method that accommodates ty files so that we can run the tests and update/move the snapshots.I had to push a fourth commit to fix and test diagnostics without a span/file.
Test Plan
Existing tests