python / python/mypy

Module has no attribute "__cached__"

Open
#9,726 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug topic-runtime-semantics
Dominant language
Python
Stars
20.6k
Forks
3.3k
PR merge metrics
PR metrics pending

Description

Bug Report

Modules have a __cached__ attribute which points at the pyc location. mypy does not understand this attribute

Here's an example bit of code:

import copyreg
print(copyreg.__cached__)

OUTPUT = '''\
/usr/lib/python3.8/__pycache__/copyreg.cpython-38.pyc
'''

To Reproduce

(Write your steps here:)

  1. Run mypy against the sample file

Expected Behavior

I expect no errors

Actual Behavior

$ mypy t.py
t.py:2: error: Module has no attribute "__cached__"
Found 1 error in 1 file (checked 1 source file)

Your Environment

  • sys.version: '3.8.5 (default, Jul 28 2020, 12:59:40) \n[GCC 9.3.0]'
  • os.name: 'posix'
  • sys.platform: 'linux'
  • platform.system(): 'Linux'
  • platform.python_implementation(): 'CPython'
  • sys.implementation.name: 'cpython'
  • sysconfig.get_platform(): 'linux-x86_64'
$ mypy --version
mypy 0.790

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by creating or running the sample file t.py with mypy 0.790 and confirm the reported error for copyreg.cached. Trace how mypy represents module attributes, then add coverage for this case and verify that mypy reports no errors for the sample.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devtools
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.