Conversation
for more information, see https://pre-commit.ci
|
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. |
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` |
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.)
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?