Skip to content

blackd-format: label stdin diffs like black, split Result.output, clarify -t - #5778

Merged
cooperlees merged 2 commits into
psf:mainfrom
IslamElsayed:blackd-format-followup
Dec 1, 2026
Merged

cooperlees merged 2 commits into
psf:mainfrom
IslamElsayed:blackd-format-followup

Conversation

@IslamElsayed

Copy link
Copy Markdown
Contributor

Description

Follow-up to #5690, covering the three nits @cooperlees left as follow-ups there:

  • STDIN label in diffs. blackd-format --diff - now labels the two sides STDIN and STDOUT, the way black --diff - does, instead of - and -.
  • Result.output split in two. It held either a diff (str) or the formatted stdin bytes, and the caller told them apart with isinstance. It is now diff: str and stdout: bytes, so each has one type and one use.
  • -t help text. It now says the version is written black's way, py312, not 3.12.

No behaviour changes beyond the stdin diff label. Two new tests: --diff - labels the sides STDIN/STDOUT, and --check - writes nothing to stdout (the case the old isinstance branch guarded).

Checklist - did you ...

  • Implement any code style changes under the --preview style, following the stability policy? (no style changes)
  • Add an entry in CHANGES.md if necessary? (this PR's number added to the existing blackd-format line, since it isn't released yet)
  • Add / update tests if necessary?
  • Add new / update outdated documentation? (help text only)

I use Claude Code when working on patches; I reviewed and tested everything here before opening the PR.

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

diff-shades results comparing this PR (3abed3a) to main (573c81e):

--preview style: no changes

--stable style: no changes


What is this? | Workflow run | diff-shades documentation

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues remain for the blackd-format diff-label and output-field refinements.

No open issues 🎉

What changed in this PR

This follow-up to #5690 refines the standard-library blackd-format client. The only intended behavior change is matching Black’s stdin diff labels.

Changes:

  • Label stdin diffs STDIN and STDOUT, with regression coverage for diff labels and silent stdout in check mode.
  • Split Result.output into typed diff and stdout fields.
  • Clarify the -t version format and update the existing changelog entry.
File Description
tests/​test_blackd_format.py Adds stdin diff-label and check-mode stdout tests.
src/​blackd_format/​__init__.py Updates diff labels, separates result outputs, and clarifies -t help.
CHANGES.md Adds this PR to the existing blackd-format entry.

Review effort: Balanced

@cooperlees cooperlees left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I agree with copilot - Thanks for the follow up. Appreciate it.

@cooperlees
cooperlees merged commit d501866 into psf:main Dec 1, 2026
54 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants