Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support decoratoring methods with curry in the MyPy plugin #82

Open
suned opened this issue Jun 15, 2021 · 0 comments
Open

Support decoratoring methods with curry in the MyPy plugin #82

suned opened this issue Jun 15, 2021 · 0 comments
Labels
enhancement New feature or request MyPy

Comments

@suned
Copy link
Owner

suned commented Jun 15, 2021

Currently, curry instances returned from decorating methods with curry doesn't eliminate the self argument, which issues a type error when trying to call a curried method:

from pfun import curry

class C:
    @curry
    def f(x: int, y: int) -> int: ...

reveal_type(C().f)  #  note: Revealed type is 'pfun.functions.Curry[def (self: test_types.C, x: builtins.int, y: builtins.int) -> builtins.int]'
C().f(1)  # error: Argument 1 to "__call__" of "Curry" has incompatible type "int"; expected "C"

The main issue in fixing this is finding a way to distinguish this call to curry with a call with an instance that has a __call__ method in e.g:

class C:
     def __call__(self, x: int, y: int) -> int: ...

curry(C())
@suned suned added enhancement New feature or request MyPy labels Jun 15, 2021
@suned suned added this to the Release version 1.0.0 milestone May 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request MyPy
Projects
None yet
Development

No branches or pull requests

1 participant