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

Add py.typed file to support mypy typing when installed #17

Merged
merged 1 commit into from
Oct 6, 2021

Conversation

thejaminator
Copy link
Contributor

Hi! I was checking out this repo. Really cool.

I had installed it locally. But when running mypy on the code, i got this error

error: Skipping analyzing "flupy": found module but no type hints or library stubs
note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports

This PR adds the py.typed file to the library such that mypy will analyze the library code.

Or is it intentional to disable mypy analyzing?

noticed that mypy infers map to return Fluent[Any]

from flupy import flu

customers: list[int] = [1, 2, 3]
reveal_type(flu(customers).map(lambda x: x + 1)) # revealed Fluent[Any]

Somehow it can be fixed by changing map signature to

def map(self, func: Callable[[T], _T1], *args: Any, **kwargs: Any) -> "Fluent[_T1]":

On mypy 0.920

@olirice
Copy link
Owner

olirice commented Oct 6, 2021

Looks great, thank you

@olirice olirice merged commit c29d0bf into olirice:master Oct 6, 2021
@olirice
Copy link
Owner

olirice commented Oct 6, 2021

I also updated the type for Fluent.map here

Your PR & ^ change are available in "flupy==1.1.8"

Any chance you'd be willing to take a look at Fluent.collect? it currently returns a Collection[T] but I'd love to have it pick up the container type from the container_type argument and return List[T] or Set[T] depending on the callable that gets passed. So far I haven't been able to figure that out.

@thejaminator
Copy link
Contributor Author

@olirice sure, i'll take a look at it. probably could do it with type bounds :)

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

Successfully merging this pull request may close these issues.

None yet

2 participants