Skip to content

Static typing with functools.partial #220

@benjaminsaljooghi

Description

@benjaminsaljooghi

Is your feature request related to a problem? Please describe.
Calls to functools.partial returns an object of the partial class which cannot be used for static typing.

Describe the solution you'd like
Pyright analyzes the args and kwargs of calls to functools.partial to perform static typing with the resulting partial object.

from functools import partial

def add(a: int, b: int) -> int:
    return a + b

add3 = partial(add, 3)

add3("hello") # Pyright should raise an error

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions