Error code for "async for" outside async function is too general #18795
Labels
bug
mypy got something wrong
topic-async
async, await, asyncio
topic-error-reporting
How we report errors
Bug Report
The error code for
"async for" outside async function [syntax]
is very general, so it is hard to disable without allowing other syntax errors.This is important to me because I want to type check Jupyter notebooks that take advantage of the autoawait feature and are written in the percent file format. With the error code being
syntax
, I would have to allow many unrelated errors to disable this error usingdisable_error_code
.I think it would be good if it used the same error code as
"await" outside function [top-level-await]
, or perhaps a new code entirely.To Reproduce
Example percent encoded notebook:
https://mypy-play.net/?mypy=latest&python=3.12&gist=ddd45a5b59946d0b423e5494af96e286
Expected Behavior
Actual Behavior
Your Environment
mypy.ini
(and other config files): NoneThe text was updated successfully, but these errors were encountered: