Support for PEP 484 Multi-line Comment Function Annotation Syntax

Answered

mypy has been doing a ton of work on their Python 2 support and it's become pretty mature - http://mypy-lang.blogspot.com/2016/07/mypy-043-released.html .  It'd be great if Pycharm could use the same set of type annotations for Python 2 method declaration so I could get the value of type checking my code with mypy and get autocomplete in Pycharm.  For example:

    def send_email(address,     # type: Union[str, List[str]]
                   sender,      # type: str
                   cc,          # type: Optional[List[str]]
                   bcc,         # type: Optional[List[str]]
                   subject='',
                   body=None    # type: List[str]
                   ):
        # type: (...) -> bool
        """Send an email message.  Return True iff successful."""

 

2 comments

Support for these annotations seems reasonably good, however there's a pretty annoying bug where the last line:

```

# type: (...) -> bool

```

Is interpreted as the `...` operator in Python 2 code, which then classifies an error: 

```

Python versions < 3.0 do not support '...' outside of sequence slicings.

```
Even though the `...` is in a type annotation :(

0

Hi David! I'm sorry for this, the problem is known and the fix in progress, please follow PY-22302.

0

Please sign in to leave a comment.