Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly handle async inner functions #1599

Closed
adamrothman opened this issue May 31, 2016 · 3 comments
Closed

Correctly handle async inner functions #1599

adamrothman opened this issue May 31, 2016 · 3 comments

Comments

@adamrothman
Copy link

adamrothman commented May 31, 2016

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.

@gvanrossum
Copy link
Member

gvanrossum commented May 31, 2016 via email

@adamrothman
Copy link
Author

Oops! Don't know how I missed #1353... Well, thanks for responding so quickly. I'll follow that issue.

@gvanrossum
Copy link
Member

Dupe of #1453.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants