[ty] Fix Gitlab codequality output format for empty diagnostics#22833
Merged
ntBre merged 5 commits intoastral-sh:mainfrom Jan 26, 2026
Merged
[ty] Fix Gitlab codequality output format for empty diagnostics#22833ntBre merged 5 commits intoastral-sh:mainfrom
ntBre merged 5 commits intoastral-sh:mainfrom
Conversation
Typing conformance resultsNo changes detected ✅ |
|
ntBre
reviewed
Jan 25, 2026
Contributor
ntBre
left a comment
There was a problem hiding this comment.
Nice! I confirmed that returning an empty list is in line with Ruff:
❯ ruff check --select I001 --output-format gitlab - <<<"1"
[]It might be worth adding a test for this case around here:
ruff/crates/ty/tests/cli/main.rs
Lines 656 to 658 in e8e8235
ntBre
approved these changes
Jan 26, 2026
Contributor
ntBre
left a comment
There was a problem hiding this comment.
Thanks! I made one simplification in line with my previous comment, but this makes sense to me.
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
Closes astral-sh/ty#2617
This PR fixes the behavior of
ty check --output-format=gitlabwhen there are no diagnostics.Previously, the output file was empty (0 bytes) if no errors were found, but GitLab expects an empty JSON list (
[]) in this case (https://docs.gitlab.com/ci/testing/code_quality/#code-quality-report-format). As stated : "The file you provide as Code Quality report artifact must contain a single JSON array."Now, when the GitLab format is selected and there are no diagnostics,
[]is written to the output file, ensuring compatibility with GitLab CI/CD.Test Plan
Ran
ty check --output-format=gitlabon a project with no errors and verified that the output file contains[].Ran
ty check --output-format=gitlabon a project with errors and verified that the output file contains the expected JSON diagnostics list.Confirmed that other output formats are unaffected.