Skip to content

Add ANN300-level Error for Mixed Ellipses and Type Comments #95

@sco1

Description

@sco1

As touched on in #92, the current definition of and support for ellipses in partial type comments clashes with guidance provided in PEP 484:

Sometimes you want to specify the return type for a function or method without (yet) specifying the argument types. To support this explicitly, the argument list may be replaced with an ellipsis. Example:

def send_email(address, sender, cc, bcc, subject, body):
    # type: (...) -> bool
    """Send an email message.  Return True if successful."""
    <code>

This plugin currently supports mixing of ellipses and types within the same type comment as a means for partial hinting. For example, from the README:

def foo(arg1, arg2):
    # type: (..., bool) -> bool
    pass

Will show arg1 as missing a type hint.

While technically valid code, this type of notation is ambiguous and causes tools like mypy to error:

error: Ellipses cannot accompany other argument types in function type signature

This issue proposes the addition of an ANN300-level error to lint for this mixing of ellipses, as well as dropping explicit support for these annotations within the framework. This is considered a breaking change and will therefore be included in a major release. The new error may be introduced in a point release for compatibility evaluation, but will remain off by default until a major release.

Metadata

Metadata

Assignees

No one assigned

    Labels

    wontfixThis will not be worked on

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions