Skip to content

functools.partial breaks templated wrapped function #8341

Closed
@crusaderky

Description

@crusaderky
from functools import partial
from typing import TypeVar

T = TypeVar("T")

def f(x: int) -> int: ...
pf = partial(f)
def g(x: T) -> T: ...
pg = partial(g)


reveal_type(f(1))
reveal_type(pf(1))
reveal_type(g(1))
reveal_type(pg(1))

Python 3.8.1, mypy 0.770+dev.be883f6770b24bc467ccb993fd77864248b61979 output:

note: Revealed type is 'builtins.int'
note: Revealed type is 'builtins.int*'
note: Revealed type is 'builtins.int*'
note: Revealed type is 'T`-1'

Expected output: int in all cases

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions