Skip to content
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

Preserve visible quote types for f-string debug expressions #4005

Merged
merged 18 commits into from Nov 8, 2023

Conversation

henriholopainen
Copy link
Contributor

@henriholopainen henriholopainen commented Oct 31, 2023

Description

Don't touch visible quotes in f-string debug expressions. From this issue.

Checklist - did you ...

  • Add an entry in CHANGES.md if necessary?
  • Add / update tests if necessary?

@github-actions
Copy link

github-actions bot commented Oct 31, 2023

diff-shades reports zero changes comparing this PR (0171326) to main (46be1f8).


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

@henriholopainen henriholopainen changed the title Treat strings with different quote types as equivalent Preserve printable quote types for debug f-strings Oct 31, 2023
Copy link
Collaborator

@hauntsaninja hauntsaninja left a comment

Choose a reason for hiding this comment

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

I don't think the regex is right, need to care about things like {foo("asdf")=} as well. Also maybe worth using iter_fexpr_spans?

@henriholopainen
Copy link
Contributor Author

I don't think the regex is right, need to care about things like {foo("asdf")=} as well. Also maybe worth using iter_fexpr_spans?

Thanks, will fix! 🙏

Copy link
Collaborator

@hauntsaninja hauntsaninja left a comment

Choose a reason for hiding this comment

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

Thanks, this looks pretty good!

src/black/trans.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@JelleZijlstra JelleZijlstra left a comment

Choose a reason for hiding this comment

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

Thank you!

src/black/trans.py Outdated Show resolved Hide resolved
tests/data/cases/preview_long_strings.py Outdated Show resolved Hide resolved
CHANGES.md Outdated Show resolved Hide resolved
@henriholopainen henriholopainen changed the title Preserve printable quote types for debug f-strings Preserve visible quote types for f-string debug expressions Nov 3, 2023
Copy link
Collaborator

@hauntsaninja hauntsaninja left a comment

Choose a reason for hiding this comment

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

I wouldn't mind a test involving :=

Copy link
Collaborator

@hauntsaninja hauntsaninja left a comment

Choose a reason for hiding this comment

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

Thank you!!!!

@JelleZijlstra
Copy link
Collaborator

diff-shades keeps failing, but it passed previously and we haven't changed anything substantial since, so I'm just going to merge.

@JelleZijlstra JelleZijlstra merged commit 1a7d9c2 into psf:main Nov 8, 2023
40 of 41 checks passed
@henriholopainen
Copy link
Contributor Author

Can we close the issue also 🙏

@JelleZijlstra
Copy link
Collaborator

@henriholopainen it's easier if you put "Fixes #3860" in your PR description :)

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.

None yet

3 participants