8000 Add type stubs · Issue #106 · Suor/funcy · GitHub
[go: up one dir, main page]

Skip to content

Add type stubs #106

@ruancomelli

Description

@ruancomelli

Stub files can be added to the project to provide static type information that can be used by tools like mypy.

I believe that the simplest way to add this functionality to funcy is to provide stub files along with their respective modules. That is, for example, a stub file colls.pyi corresponding to the contents of colls.py; a funcs.pyi corresponding to funcs.py and so on. Corresponding snippets from funcs.py and funcs.pyi would look like:

funcs.py

def identity(x):
    return x

def constantly(x):
    return lambda *a, **kw: x

def caller(*a, **kw):
    return lambda f: f(*a, **kw)

funcs.pyi

from typing import Any, Callable, TypeVar

T = TypeVar('T')

def identity(x: T) -> T: ...
def constantly(x: T) -> Callable[..., T]: ...
def caller(*a: Any, **kw: Any) -> Callable[[Callable[..., T]], T]: ...

Take a look at more-itertools to see how this looks like when fully implemented.

If you are interested in this functionality, I could perhaps submit a draft PR by the end of the week.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0