Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

PyCharm can't recognizes that Case is callable and etc. #36

Open
rscarrera27 opened this issue Apr 24, 2020 · 1 comment
Open

PyCharm can't recognizes that Case is callable and etc. #36

rscarrera27 opened this issue Apr 24, 2020 · 1 comment

Comments

@rscarrera27
Copy link

My Code:

@adt
class Result(Generic[S, E]):
    Success: Case[S]
    Error: Case[E]

    async def map(self, func: Callable[[S], Awaitable[Union[S, E]]]) -> "Result[S, E]":
        return self.match(success=lambda s: self.Success(func(s)), error=lambda e: e)

    async def flat_map(self, func: Callable[[S], Awaitable["Result[S, E]"]]) -> "Result[S, E]":
        return self.match(success=lambda s: (await func(s)), error=lambda e: e)

Pycharm said "Case object is not callable" for this line.

self.Success(func(s))

also intellisense doesn't work for completing self.match

I understand that this is architectural issue. to make pycharm intellisense work, I think we have to use base class, not use decorator.

this is just a suggestion. your lib works perfectly on runtime :)

@LewisGaul
Copy link

As someone who uses PyCharm and was looking into options for ADTs in Python - I'm not surprised it causes issues with PyCharm's intellisense, and I doubt there will be anything that can really be done about it. I'd love to be proven wrong, but in general it's not possible for metaprogramming to be followed without actually running the code, which IDEs can't be expected to do!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants