Closed
Description
This appears to be similar to #1551 but is somewhat more of a problem as the error occurs even when mypy
attempts to parse un-annotated code.
mypy
doesn't mind this code at all:
def get_printer(thing):
def printer():
print(thing)
return printer
But if the inner function is defined as a coroutine using async
/await
syntax, like so:
def get_async_printer(thing):
async def aprinter():
print(thing)
return aprinter
mypy
throws a bunch of errors:
$ mypy ./mypy-workout.py
mypy-workout.py: note: In function "get_async_printer":
mypy-workout.py:9: error: Parse error before "def"
mypy-workout.py:9: error: Parse error before :
mypy-workout.py:10: error: Inconsistent indentation
mypy-workout.py: note: At top level:
mypy-workout.py:15: error: Inconsistent indentation
This happens whether the file is annotated with type hints or not.