Skip to content

Conversation

@maxmynter
Copy link
Contributor

Closes #16640

Summary

Added a check for escaped quotes in triple quotes to determine if chaperone spaces are needed.
This prevents unwanted formatting of valid docstrings that end in escaped quotes.

Test Plan

Added a unit test testing that docstrings ending in escaped double quotes are not reformatted.

@maxmynter maxmynter requested a review from MichaReiser as a code owner April 5, 2025 05:30
@github-actions
Copy link
Contributor

github-actions bot commented Apr 5, 2025

ruff-ecosystem results

Formatter (stable)

✅ ecosystem check detected no format changes.

Formatter (preview)

✅ ecosystem check detected no format changes.

@MichaReiser MichaReiser added the breaking Breaking API change label Apr 5, 2025
@AlexWaygood AlexWaygood added the formatter Related to the formatter label Apr 5, 2025
@maxmynter maxmynter requested a review from MichaReiser April 8, 2025 13:32
@MichaReiser MichaReiser added preview Related to preview mode features and removed breaking Breaking API change labels Apr 11, 2025
class Sample:
"""Needs chaperone\\" """

"""Needs chaperone\\\ """
Copy link
Member

@MichaReiser MichaReiser Apr 11, 2025

Choose a reason for hiding this comment

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

This file doesn't test the chaperone handling except for the first string because all subsequent strings aren't docstrings.

@MichaReiser MichaReiser merged commit 1aad180 into astral-sh:main Apr 11, 2025
22 checks passed
dcreager added a commit that referenced this pull request Apr 11, 2025
* main:
  [red-knot] Specialize `str.startswith` for string literals (#17351)
  [syntax-errors] `yield`, `yield from`, and `await` outside functions (#17298)
  [red-knot] Refresh diagnostics when changing related files (#17350)
  Add `Checker::import_from_typing` (#17340)
  Don't add chaperone space after escaped quote in triple quote (#17216)
  [red-knot] Silence errors in unreachable type annotations / class bases (#17342)
@dylwil3 dylwil3 mentioned this pull request Sep 19, 2025
31 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

formatter Related to the formatter preview Related to preview mode features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unexpected space in docstring near escaped quote

3 participants