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 marker and stub for decorator type #32

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ronyb29
Copy link

@ronyb29 ronyb29 commented Jul 20, 2024

Hey nice lib,

I'm trying to make it "mypy-friendly".

tested on py3.11 with this stub, but it should work for older versions too

from memoize.configuration import DefaultInMemoryCacheConfiguration
from memoize.wrapper import memoize


@memoize(configuration=DefaultInMemoryCacheConfiguration())
async def get_value(arg: str, *, kwarg: str = None) -> str:
    return arg + (kwarg or '')

reveal_type(get_value)

before would yield

checktypes.py:9: note: Revealed type is "Any"

now yields

checktypes.py:9: note: Revealed type is "def (arg: builtins.str, *, kwarg: Union[builtins.str, None] =) -> typing.Coroutine[Any, Any, builtins.str]"



@overload
def memoize(*, configuration: CacheConfiguration = None,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

configuration and invalidation are optional and should be marked accordingly (Optional from typing).

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.

2 participants