Skip to content

Don't add chaperone space after escaped quote in triple quote #17216

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 11, 2025

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
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)
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
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy