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

Cannot infer type argument 1 of Nothing.and_then + other type issues with Maybe #89

Closed
ericgj opened this issue Sep 12, 2021 · 1 comment · Fixed by #91
Closed

Cannot infer type argument 1 of Nothing.and_then + other type issues with Maybe #89

ericgj opened this issue Sep 12, 2021 · 1 comment · Fixed by #91
Labels
bug Something isn't working MyPy

Comments

@ericgj
Copy link

ericgj commented Sep 12, 2021

Minimal example:

from pfun.maybe import Maybe, Just, Nothing

def test_and_then() -> Maybe[int]:
   nope: Maybe[int] = Nothing()
   return nope.and_then(lambda x: Just(x + 1))

def test_map() -> Maybe[int]:
   nope: Maybe[int] = Nothing()
   return nope.map(lambda x: x + 1)

The first one results in:
Cannot infer type argument 1 of "and_then" of "Nothing"

The second:
Returning Any from function declared to return int

The second one seems to be because it is picking up the signature of the ABC: Maybe_.map.

I am using the pfun.mypy_plugin.

Thanks for this very promising library!

@suned
Copy link
Owner

suned commented Sep 16, 2021

Thanks for the report!

The first one is likely because of limitations of type inference of lambdas in mypy itself, so not sure there is much to do there unfortunately.

I'll look into the second one, might be as you say because of the ABC. I may remove that, since it doesn't really make any sense anyway.

@suned suned added MyPy bug Something isn't working labels Sep 17, 2021
@suned suned closed this as completed in #91 Sep 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working MyPy
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants