Skip to content

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

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

Closed
diogobaeder opened this issue Jun 7, 2020 · 5 comments
Closed

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

diogobaeder opened this issue Jun 7, 2020 · 5 comments

Comments

@diogobaeder
Copy link

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.

@JelleZijlstra JelleZijlstra transferred this issue from python/mypy Jun 7, 2020
@JelleZijlstra
Copy link
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.

@diogobaeder
Copy link
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?

@hauntsaninja
Copy link
Collaborator

hauntsaninja commented Jun 7, 2020

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.

@hauntsaninja
Copy link
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!

@diogobaeder
Copy link
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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants