You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Module 'functools' has no attribute 'cached_property' #4198
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.
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.
Reacted by Vladimir Vargas-Calderón and Hany Hamed
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?
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.
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.
Activity
JelleZijlstra commentedon Jun 7, 2020
This was fixed in #3439, which was released by mypy a while ago. Are you running mypy with
--python-version 3.8?functools.cached_propertydidn't exist before 3.8.diogobaeder commentedon Jun 7, 2020
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 commentedon 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 commentedon Jun 11, 2020
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 commentedon Jun 13, 2020
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!