Skip to content

@cache.memoize discard the typehint in origin function. #41

@ramwin

Description

@ramwin

here is my code

@cache.memoize()
def slow(x: int) -> str:
    LOGGER.info("调用: %d", x)
    return str(x)


def main() -> None:
    LOGGER.info("show(1): ")
    LOGGER.info(slow(1))
    time.sleep(0.3)
    LOGGER.info("show(2): ")
    LOGGER.info(slow(2))
    time.sleep(0.7)
    LOGGER.info("show(1): ")
    LOGGER.info(slow(1))
    LOGGER.info("show(2): ")
    LOGGER.info(slow('2'))

what I expect:

[#7#wangx@manjaroamd:other_useful_library[master] $ mypy test_cacheout.py
test_cacheout.py:37: error: Argument 1 to "slow" has incompatible type "str"; expected "int"  [arg-type]
Found 1 error in 1 file (checked 1 source file)

what really happened

[#9#wangx@manjaroamd:other_useful_library[master] $ mypy test_cacheout.py
Success: no issues found in 1 source file

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