Skip to content

scripts/update_schemastore: add text=True to git revision check_output calls#3523

Merged
dhruvmanila merged 6 commits into
astral-sh:mainfrom
Dev-X25874:fix/update-schemastore-bytes-revision-output
May 26, 2026
Merged

scripts/update_schemastore: add text=True to git revision check_output calls#3523
dhruvmanila merged 6 commits into
astral-sh:mainfrom
Dev-X25874:fix/update-schemastore-bytes-revision-output

Conversation

@Dev-X25874

Copy link
Copy Markdown
Contributor

Summary

main() in scripts/update_schemastore.py calls check_output twice to read
git SHAs — once for the expected ruff submodule revision and once for the actual
HEAD of the submodule — but neither call passes text=True. Without it,
check_output returns bytes, and when those values are interpolated into the
mismatch warning f-string the user sees raw bytes repr in their terminal:

The ruff submodule is at b'def456...' but main expects b'abc123...'

instead of the intended:

The ruff submodule is at def456... but main expects abc123...

The same main() already uses text=True correctly for the current_sha
call on line 81. This PR makes the two revision-check calls consistent with
that pattern.

Test Plan

Added scripts/tests/test_update_schemastore.py with a test that monkey-patches
check_output to return the mismatched-revision case, captures stdout, and
asserts the output contains plain SHA strings without any b'...' wrapper.
The test fails against the original code and passes after the fix.

python -m pytest scripts/tests/test_update_schemastore.py -v

@Dev-X25874 Dev-X25874 closed this May 23, 2026
@Dev-X25874 Dev-X25874 reopened this May 23, 2026
@Dev-X25874

Copy link
Copy Markdown
Contributor Author

The only remaining failure is a mdformat blank line issue caused by GitHub's web editor mangling the formatting. Happy for a maintainer to fix it directly or I can push a local fix if needed.

@dhruvmanila dhruvmanila self-assigned this May 26, 2026
@dhruvmanila dhruvmanila added the internal An internal refactor or improvement label May 26, 2026

@dhruvmanila dhruvmanila left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you.

I'm going to remove the test file given that these are scripts and we usually don't write tests for it. I'm also updating the print call to use !r so that the quotes are present in the output.

@dhruvmanila dhruvmanila merged commit 8f1cee0 into astral-sh:main May 26, 2026
15 checks passed
@Dev-X25874

Copy link
Copy Markdown
Contributor Author

Thank you for the review and for taking the time to clean things up! Totally understand the no-tests policy for scripts — good to know for future contributions. The !r approach is a neat solution. Appreciate you merging this! 🙏

@Dev-X25874 Dev-X25874 deleted the fix/update-schemastore-bytes-revision-output branch May 26, 2026 05:21
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.

2 participants