Skip to content

async/await checks are too aggressive and even escape type: ignore #2959

Closed

Description

@timabbott

I happen to use a third-party library (Mandrill) that has various functions that take the async keyword:

https://mandrillapp.com/api/docs/index.python.html

The error is this, and it applies even if you add a type: ignore on the affected line:
/tmp/foo.py:1: error: 'async' and 'await' will become reserved keywords in Python 3.7

def foo(async=True):                                                                                 
    pass                                                                                             
                                                                                                     
foo(async=False)  # type: ignore                                                                     

You get the same thing with even this:

x = dict(async=False)  # type: ignore                                                                

Other keywords don't have this problem (x = dict(type=False) works fine), so I think this is just a bug with this new friendly check for new keywords.

I worked around this by passing **{'async': False} instead, but it's kinda absurd.

Activity

  1. JelleZijlstra commented on Mar 4, 2017

    @JelleZijlstra
    Member

    I ran into this too. It might be an issue with typed-ast instead but I haven't looked into details yet.

  2. gvanrossum commented on Mar 5, 2017

    @gvanrossum
    Member

    There are two meanings of the term "keyword". Here, async and await will become reserved words of the language. type is just a "keyword argument". This really means that Mandrill will have to change.

    Yet until then I agree that it would be nice if we could suppress the warning somehow. That may require a typed-ast change. @ddfisher?

  3. ddfisher commented on Mar 6, 2017

    @ddfisher
    Collaborator

    Oops, this is definitely a bug in typed-ast. I accidentally turned a conditional warning into an unconditional error when making some fixes for Python 3.3 compatibility. I don't think it's typed-ast's place to warn about this error, so I'm going to remove it instead.

  4. ddfisher commented on Mar 6, 2017

    @ddfisher
    Collaborator

    I'll release 1.0.2 to PyPI as soon as the wheels finish building.

  5. ddfisher commented on Mar 6, 2017

    @ddfisher
    Collaborator

    Released typed-ast 1.0.2.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions