Open jakkdl opened 1 week ago
I can try to pick this one up if it helps :)
@josetapadas Please, feel free! You can check out CONTRIBUTING.md and the Developer Guides for contributing guidelines and tips on where to start. Thanks!
hi there @brianschubert , I've opened https://github.com/python/mypy/pull/18152 to try and address this issue.
(So this is my first attempt to contribute to this great project so any guidance on a mistakeful approach would be very appreciated! :see_no_evil:)
I've attempted to as well use a file like the one in the example to verify the fix:
╰─❯ cat -n foo.py
1 def foo():
2 yield 0
3
4
5 def lol():
6 (await x for x in foo())
7 [x async for x in foo()]
8 {k: v async for k, v in foo()}
9 (x for x in await foo())
10 [await x for x in foo()]
11 (x async for x in foo())
to verify if the errors were in the proper place:
╰─❯ rm -rf .mypy_cache && mypy foo.py --show-traceback
foo.py:7: error: "async for" outside async function [syntax]
foo.py:8: error: "async for" outside async function [syntax]
foo.py:9: error: "await" outside coroutine ("async def") [await-not-async]
foo.py:10: error: "await" outside coroutine ("async def") [await-not-async]
Found 4 errors in 1 file (checked 1 source file)
Bug Report
await-not-async does not warn on
async for
in list and dict comprehensions, and incorrectly does give a warning forawait
insideGeneratorExp.elt
. For list & dict comprehensions you should error on anyawait
orasync for
, but for generator expressions it's only the generator that should be checked.To Reproduce
Expected Behavior
It should error on 8, 9, 12 and 13
Actual Behavior
Your Environment
mypy.ini
(and other config files):also see https://github.com/astral-sh/ruff/issues/14167 that had the exact same issues