mypy 1.0.0 does not include error code for "await" outside function
so it cannot be ignored when linting notebooks
#14763
Labels
"await" outside function
so it cannot be ignored when linting notebooks
#14763
Bug Report
In mypy 0.991, mypy would assign error code "misc" when
await
was used outside a function. Though "misc" is non-specific, having an error code allowed for ignoring these errors when linting Jupyter notebook files (usingnbqa mypy file.ipynb
with nbqa). Jupyter notebooks already automatically run cells in an async awaited eventloop context (see here), so it's important to be able to ignore these top-levelawait
usages in ipynb files. For instance, Pylance added logic to handle this situation directly here microsoft/pylance-release#1754 (comment).As of mypy 1.0.0, mypy no longer assigns an error code when
await
is used outside a function, and treats it as a blocking error that prevents further checking. This means it's now no longer possible to lint notebook files that useawait
with mypy+nbqa.I'm guessing this change in behavior was introduced in #14486 here
To Reproduce
Run
await
in the top level of some file (notebook or otherwise):Compare:
Expected Behavior
mypy does not halt further checking, and mypy uses an error-code for
"await" outside function
, so that users can choose to disable the warning when that occurs. That will allow mypy to continue to be used/useful for Jupyter notebook files (for instance, setting--disable-error-code=misc
when usingnbqa
).Actual Behavior
mypy returns a blocking error and does not provide a workaround.
Your Environment
--disable-error-code=misc
mypy.ini
(and other config files): anyThe text was updated successfully, but these errors were encountered: