Skip to content

functools.partial no longer matches docs #3080

@scop

Description

@scop

In mypy 0.710 due to I suppose commit e45f443, functools partial no longer corresponds with the docs, https://docs.python.org/3/library/functools.html#partial-objects

The docs state they're objects with func, args, and keywords, but they're no longer defined as such, thus cannot be annotated as partial, cannot access the documented attributes etc. For example, this resulted in no problem output with mypy 0.701:

from functools import partial
from typing import Callable

def foo(bar: Callable) -> None:
    func = bar
    while isinstance(func, partial):
        func = func.func

...but now with 0.710 gives:

t.py:6: error: Argument 2 to "isinstance" has incompatible type overloaded function; expected "Union[type, Tuple[Union[type, Tuple[Any, ...]], ...]]"
t.py:7: error: "Callable[..., Any]" has no attribute "func"

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