Draft
Conversation
for more information, see https://pre-commit.ci
Contributor
|
diff-shades results comparing this PR (ebefed8) to main (1b08cbc). The full diff is available in the logs under the "Generate HTML diff report" step. |
Collaborator
JelleZijlstra
left a comment
There was a problem hiding this comment.
I ran this diff also on our internal codebase, which very heavily uses yield because of https://github.com/quora/asynq. Most of the changes are clear improvements, but I noticed a few cases like this:
- content_type = yield (
- a.model.tribe.item.TribeItem(tribe_item_id).get_content_type.asynq()
- )
+ content_type = yield a.model.tribe.item.TribeItem(
+ tribe_item_id
+ ).get_content_type.asynq()
Here the old formatting seems better.
There are also cases like this:
cant_edit = (
- yield a.controller.tribe.item.is_tribe_answer_and_cant_edit.asynq(
- self.aid, self.viewer
+ yield (
+ a.controller.tribe.item.is_tribe_answer_and_cant_edit.asynq(
+ self.aid, self.viewer
+ )
)
)
Where ideally we should remove the outer set of parentheses.
Linking #1553, another issue with how we manage yields; it may make sense to tackle them together.
| <!-- Changes that affect Black's stable style --> | ||
|
|
||
| - Fix comments getting removed from inside parenthesized strings (#3909) | ||
| - Parenthesize singleton tuples in `yield` expressions as they already are in `return` |
Collaborator
There was a problem hiding this comment.
This needs to go in the preview style, not the stable style. (That's also why CI is failing.)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Closes #3851
Please let me know if I should be going along a different path c^:
I had originally intended to make a
visit_yield_expr = partial(v, keywords={"yield"}, parens={"yield"})to be more similar toreturnalongside this, but that doesn't work sinceyieldcan be an expression butreturncan't.black/src/black/linegen.py
Line 527 in 1b08cbc
Checklist - did you ...
CHANGES.mdif necessary?