Skip to content

Inferring constraints for callable types doesn't verify argument counts and kinds #702

Closed

Description

@JukkaL

The method mypy.constraints.ConstraintBuildervisitor.visit_callable_type is pretty broken. It assumes that there are no *args, **kwargs and that the callable types are generally compatible.

This issue may be already filed, but adding it now so that I won't forget about it.

Activity

  1. ddfisher commented on Mar 2, 2016

    @ddfisher
    Collaborator

    @JukkaL can you clarify with some concrete problems?

  2. JukkaL commented on May 17, 2018

    @JukkaL
    CollaboratorAuthor

    Here is an example that produces incorrect output (though the example isn't realistic):

    from typing import TypeVar, Callable, Tuple
    
    T = TypeVar('T')
    S = TypeVar('S')
    
    def f(x: Callable[[T, S], None]) -> Tuple[T, S]:
        pass
    
    def g(*x: int) -> None: pass
    
    reveal_type(f(g))  # Tuple[int, <nothing>]

    The expected output is Tuple[int, int].

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

    bugmypy got something wrongfalse-positivemypy gave an error on correct codepriority-1-normaltopic-callsFunction calls, *args, **kwargs, defaults

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions