No type checking for thread local variables?
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
Research direction
Start by reproducing both snippets with --disallow-untyped-defs and --disallow-untyped-calls, then inspect how mypy handles attributes on threading.local(). Compare the unannotated mixed-key assignments with the rejected attribute annotation; done means the intended checking and annotation behavior is covered by regression tests.
Written by the indexing model from the issue text.
Description
The following type checks without errors even though I am running with "--disallow-untyped-defs --disallow-untyped-calls".
import threading
_parameter_values = threading.local()
_parameter_values.data = {}
_parameter_values.data[3] = "hello"
_parameter_values.data["hello"] = 3
and if I deliberately try to add annotations:
import threading
_parameter_values = threading.local()
_parameter_values.data: Dict[int, str] = {}
_parameter_values.data[3] = "hello"
then I get the following error:
error: Type cannot be declared in assignment to non-self attribute
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 54
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from python/mypy
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
bug topic-configuration topic-error-reporting
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Similar issues
-
link-check link-check:sphinx-theme
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
qgis/QGIS-Documentation#11275 ·
-
bug priority:normal ready-for-dev
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
OpenHands/extensions#626 · 1 comment ·
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
CSCfi/sd-search-api#39 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100