suned / pfun

Functional, composable, asynchronous, type-safe Python.
https://pfun.dev/
MIT License
151 stars 14 forks source link

mypy error using effect.combine #90

Closed ericgj closed 3 years ago

ericgj commented 3 years ago

Minimal example:

from typing import TypeVar, Any
from pfun.effect import Try, combine, catch

A = TypeVar("A")

def test(*effects: Try[Exception,A]) -> Try[Exception,None]:
    return combine(*effects)(lambda *a: None)

Blows up with a mypy internal error:

image

It doesn't matter if I move that lambda to a function.

(Probably a mypy issue, as I tried with the latest dev version of mypy (0.920dev) and didn't get the error. But note I had to disable the pfun mypy_plugin on the dev version, got a different error.)

suned commented 3 years ago

Thanks for the report! The issue seems to be the use of starags which isn't handled correctly in the plugin. I think this needs to be special cased unfortunately, so it might take a moment before I can produce a fix

ericgj commented 3 years ago

No worries, I didn't end up needing combine for what I was doing. I did wonder if a non-starargs version of combine, lift, etc would work better.

suned commented 3 years ago

Good to hear.

I did wonder if a non-starargs version of combine, lift, etc would work better.

it would be easier to type, but you would have to write overloaded definitions for some number of arguments, so it would also be less flexible.