Skip to content

type hint: how should type of lru_cache be defined? #5107

Closed as not planned
Closed as not planned
@david-gang

Description

@david-gang

Note: if you are reporting a wrong signature of a function or a class in
the standard library, then the typeshed tracker is better suited
for this report: https://github.com/python/typeshed/issues

Please provide more information to help us understand the issue:

  • Are you reporting a bug, or opening a feature request? bug
  • Please insert below the code you are checking with mypy,
    or a mock-up repro if the source is private. We would appreciate
    if you try to simplify your case to a minimal repro.
@lru_cache(maxsize=1)
def get_response_from_api() -> List[ApiObject]:
    url = _get_api_url()
    response = requests.get(url).text
    return json.loads(response, object_hook=_create_api_obj)
  • What is the actual behavior/output?

error: Untyped decorator makes function "get_response_from_api" untyped

  • What is the behavior/output you expect?
    it should not emit an error, alternatively there should be instructions what to do.

  • What are the versions of mypy and Python you are using?
    mypy 0.600
    python 3.6.5
    Do you see the same issue after installing mypy from Git master? did not try

  • What are the mypy flags you are using? (For example --strict-optional)
    mypy predictor --ignore-missing-imports --strict

  • If mypy crashed with a traceback, please paste
    the full traceback below.

Also asked in SO: https://stackoverflow.com/questions/50495759/type-hint-how-should-type-of-lru-cache-be-defined

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions