Skip to content

Concatenate[str, bool, Q] spuriously duplicated to Concatenate[str, bool, str, bool, Q] #12734

Closed
@andersk

Description

@andersk

Mypy gives a false positive on this valid code. The error message seems to indicate that it’s spuriously duplicated the str, bool parameters to str, bool, str, bool somewhere.

from typing import Callable, Concatenate, ParamSpec

P = ParamSpec("P")
Q = ParamSpec("Q")

def foo(f: Callable[P, int]) -> Callable[P, int]:
    return f

def bar(f: Callable[Concatenate[str, bool, Q], int]) -> Callable[Concatenate[str, bool, Q], int]:
    return foo(f)

Mypy playground link

main.py:10: error: Incompatible return value type (got "Callable[[str, bool, str, bool, **Q], int]", expected "Callable[[str, bool, **Q], int]")
main.py:10: error: Argument 1 to "foo" has incompatible type "Callable[[str, bool, **Q], int]"; expected "Callable[[str, bool, str, bool, **Q], int]"
Found 2 errors in 1 file (checked 1 source file)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrongtopic-paramspecPEP 612, ParamSpec, Concatenate

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions