Skip to content

Module 'functools' has no attribute 'cached_property' #4198

Closed

Description

@diogobaeder

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?
    Reporting a 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.
    from functools import cached_property

  • What is the actual behavior/output?
    mypy check error: Module 'functools' has no attribute 'cached_property' - the code however runs just fine.

  • What is the behavior/output you expect?
    That mypy succeeds with that line, instead of failing, since the attribute does exist.

  • What are the versions of mypy and Python you are using?
    mypy 0.770, CPython 3.8.3

  • Do you see the same issue after installing mypy from Git master?
    Yes.

  • What are the mypy flags you are using? (For example --strict-optional)
    No flags.

Activity

  1. transferred this issue frompython/mypyon Jun 7, 2020
  2. JelleZijlstra commented on Jun 7, 2020

    @JelleZijlstra
    Member

    This was fixed in #3439, which was released by mypy a while ago. Are you running mypy with --python-version 3.8? functools.cached_property didn't exist before 3.8.

  3. diogobaeder commented on Jun 7, 2020

    @diogobaeder
    Author

    Ah, interesting, that works! I was not specifying the minor version, why is that necessary? Does mypy imply some other minor version if I don't specify it?

  4. hauntsaninja commented on Jun 7, 2020

    @hauntsaninja
    Collaborator

    Could you share the command you're running? mypy doesn't allow you to specify only the major version. If you don't specify anything, mypy will use the version of sys.version_info, aka whatever Python you're using to run mypy.

  5. hauntsaninja commented on Jun 11, 2020

    @hauntsaninja
    Collaborator

    Closing, as I believe there aren't any changes to be made on typeshed's side — but feel free to post / reopen if you're still having trouble!

  6. diogobaeder commented on Jun 13, 2020

    @diogobaeder
    Author

    Hi @hauntsaninja , I tried with the argument suggested by @JelleZijlstra and it worked. It's surprising that even running it under Python 3.8 requires me to provide that argument, but IMO that's not a big issue, provided that it works I'm fine with that.

    Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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