Skip to content

PYTHON-6263 Remove the blacken-docs pre-commit hook - #3214

Merged
aclark4life merged 2 commits into
mongodb:mainfrom
aclark4life:PYTHON-6263
Nov 12, 2026
Merged

aclark4life merged 2 commits into
mongodb:mainfrom
aclark4life:PYTHON-6263

Conversation

@aclark4life

Copy link
Copy Markdown
Contributor

PYTHON-6263

Changes in this PR

  • Removes the blacken-docs hook from .pre-commit-config.yaml.
  • Removes the now dead blacken-docs:off/on skip markers from CODING-STANDARDS.md.

The hook formatted code samples in docs with the pinned black 22.3.0 while the repo formatter is ruff, and it failed the static job on #3131 by rewriting CONTRIBUTING.md.

Test Plan

  • uvx pre-commit run --all-files --hook-stage manual passes.

Checklist

Checklist for Author

  • Did you update the changelog (if necessary)?
  • Is the intention of the code captured in relevant tests?
  • If there are new TODOs, has a related JIRA ticket been created?

Checklist for Reviewer

  • Does the title of the PR reference a JIRA Ticket?
  • Do you fully understand the implementation? (Would you be comfortable explaining how this code works to someone else?)
  • Have you checked for spelling & grammar errors?
  • Is all relevant documentation (README or docstring) updated?

@aclark4life
aclark4life marked this pull request as ready for review November 11, 2026 22:56
@aclark4life
aclark4life requested a review from a team as a code owner November 11, 2026 22:56
@aclark4life
aclark4life requested review from NoahStapp and a balanced review from Copilot November 11, 2026 22:56

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 block the removal of the documentation-formatting hook and obsolete skip markers.

No open issues 🎉

What changed in this PR

Removes the documentation-formatting hook that used pinned Black 22.3.0 alongside the repository’s Ruff formatter, addressing the unwanted documentation rewrites reported in #3131.

Changes:

  • Removes the blacken-docs pre-commit hook and its Black dependency.
  • Removes obsolete skip-marker comments from the coding standards without changing the guidance.
File Description
CODING-STANDARDS.md Removes the unused blacken-docs:off/on comments.
.pre-commit-config.yaml Removes the blacken-docs hook and pinned Black dependency.

Review effort: Balanced

@NoahStapp

Copy link
Copy Markdown
Contributor

We should turn on ruff's markdown code formatting and docstring formatting if we remove blacken-docs. It'll probably cause some formatting changes but we still want full linting coverage.

@NoahStapp NoahStapp 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.

See comment above.

@aclark4life

Copy link
Copy Markdown
Contributor Author

We should turn on ruff's markdown code formatting and docstring formatting if we remove blacken-docs. It'll probably cause some formatting changes but we still want full linting coverage.

We should, but I'm not sure that it should be done in this PR, because the replacement is not equivalent to what it replaces:

  • blacken-docs formatted code blocks and left doctest structure alone. docstring-code-format deletes the bare ... continuation markers and injects blank lines inside doctest examples. That changes how the doctest job parses those examples so code that passed before can fail after.
  • We have 22 files of doctest examples that CI executes so the formatter's edits are not cosmetic. Verifying means running the doctest job and reviewing and fixing each diff.
  • The diff also rewrites user-facing examples ({'$match': ...} becomes {"$match": ...}) so it drags review of rendered docs into a config PR.

If we do everything in this PR and the doctest job fails after the PR merges the fix is to disable docstring-code-format, but the reformatting commit and the hook removal are in the same branch so reverting the branch also brings blacken-docs back! Separate PRs let you revert the formatting without undoing the hook removal.

@aclark4life aclark4life changed the title PYTHON-6263 Drop the blacken-docs pre-commit hook PYTHON-6263 Remove the blacken-docs pre-commit hook Nov 12, 2026
@NoahStapp

Copy link
Copy Markdown
Contributor

We should turn on ruff's markdown code formatting and docstring formatting if we remove blacken-docs. It'll probably cause some formatting changes but we still want full linting coverage.

We should, but I'm not sure that it should be done in this PR, because the replacement is not equivalent to what it replaces:

* `blacken-docs` formatted code blocks and left doctest structure alone. `docstring-code-format` deletes the bare `...` continuation markers and injects blank lines inside doctest examples. That changes how the doctest job parses those examples so code that passed before can fail after.

* We have 22 files of doctest examples that CI executes so the formatter's edits are not cosmetic. Verifying means running the doctest job and reviewing and fixing each diff.

* The diff also rewrites user-facing examples `({'$match': ...} becomes {"$match": ...})` so it drags review of rendered docs into a config PR.

If we do everything in this PR and the doctest job fails after the PR merges the fix is to disable docstring-code-format, but the reformatting commit and the hook removal are in the same branch so reverting the branch also brings blacken-docs back! Separate PRs let you revert the formatting without undoing the hook removal.

Sounds good, can you open a follow-up ticket to turn on ruff's formatting?

@aclark4life
aclark4life merged commit c337de3 into mongodb:main Nov 12, 2026
30 of 31 checks passed
@aclark4life
aclark4life deleted the PYTHON-6263 branch November 12, 2026 16:15
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