Skip to content

Mypy should report errors when bpo-33346 would occur #14256

Open
@jhance

Description

@jhance

https://bugs.python.org/issue33346 details some cases where you would get

SyntaxError: asynchronous comprehension outside of an asynchronous function

in some versions of Python, but mypy doesn't complain about these cases. Arguably this isn't necessarily specific to type checking, but it would be nice to report an error if Python is going to give a syntax error (even though it parses!)

I'm not quite sure what version of Python the fix (python/cpython@054e9c8) is in, but it would be nice to give an error message like "await cannot be used in dict comprehensions" in older versions of Python - especially because the error Python gives at runtime is not so good and doesn't include a line number, which gives a subpar experience trying to fix it - something mypy could provide a solution for.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions