Skip to content

Type a Callable Arg without typing the positional args before it #5017

@iddan

Description

@iddan
  • Are you reporting a bug, or opening a feature request? feature request
  • Please insert below the code you are checking with mypy,
    or a mock-up repro if the source is private. We would appreciate
    if you try to simplify your case to a minimal repro.
O = TypeVar('O')

def decorator(method : Callable[[O, VarArg(), KwArg()], Any]) -> Callable[[VarArg(), O, KwArg()], Any]:
    def x(*args, **kwargs):
        return method(args[-1], *args[0:-1], **kwargs)
    return x
  • What is the actual behavior/output?

Required positional args may not appear after default, named or var args

  • What is the behavior/output you expect?

VarArg() or ... to represent the positional args before O

  • What are the versions of mypy and Python you are using? 0.600, Python 3.6.2
    Do you see the same issue after installing mypy from Git master? Git is the same as release
  • What are the mypy flags you are using? (For example --strict-optional): No flags

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions