Fix unsafe cast in linegen.py w/ await yield handling (#3533)
Fixes #3532.
This commit is contained in:
parent
f4ebc68320
commit
226cbf0226
@ -42,6 +42,7 @@
|
|||||||
- Fix an invalid quote escaping bug in f-string expressions where it produced invalid
|
- Fix an invalid quote escaping bug in f-string expressions where it produced invalid
|
||||||
code. Implicitly concatenated f-strings with different quotes can now be merged or
|
code. Implicitly concatenated f-strings with different quotes can now be merged or
|
||||||
quote-normalized by changing the quotes used in expressions. (#3509)
|
quote-normalized by changing the quotes used in expressions. (#3509)
|
||||||
|
- Fix crash on `await (yield)` when Black is compiled with mypyc (#3533)
|
||||||
|
|
||||||
### Configuration
|
### Configuration
|
||||||
|
|
||||||
|
@ -1223,7 +1223,8 @@ def remove_await_parens(node: Node) -> None:
|
|||||||
# N.B. We've still removed any redundant nested brackets though :)
|
# N.B. We've still removed any redundant nested brackets though :)
|
||||||
opening_bracket = cast(Leaf, node.children[1].children[0])
|
opening_bracket = cast(Leaf, node.children[1].children[0])
|
||||||
closing_bracket = cast(Leaf, node.children[1].children[-1])
|
closing_bracket = cast(Leaf, node.children[1].children[-1])
|
||||||
bracket_contents = cast(Node, node.children[1].children[1])
|
bracket_contents = node.children[1].children[1]
|
||||||
|
if isinstance(bracket_contents, Node):
|
||||||
if bracket_contents.type != syms.power:
|
if bracket_contents.type != syms.power:
|
||||||
ensure_visible(opening_bracket)
|
ensure_visible(opening_bracket)
|
||||||
ensure_visible(closing_bracket)
|
ensure_visible(closing_bracket)
|
||||||
|
@ -77,6 +77,9 @@ async def main():
|
|||||||
async def main():
|
async def main():
|
||||||
await (await (await (await (await (asyncio.sleep(1))))))
|
await (await (await (await (await (asyncio.sleep(1))))))
|
||||||
|
|
||||||
|
async def main():
|
||||||
|
await (yield)
|
||||||
|
|
||||||
# output
|
# output
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
@ -167,3 +170,7 @@ async def main():
|
|||||||
|
|
||||||
async def main():
|
async def main():
|
||||||
await (await (await (await (await asyncio.sleep(1)))))
|
await (await (await (await (await asyncio.sleep(1)))))
|
||||||
|
|
||||||
|
|
||||||
|
async def main():
|
||||||
|
await (yield)
|
||||||
|
Loading…
Reference in New Issue
Block a user