reveal_locals() doesn't show module globals that are annotated
Open
Nobody has claimed this yet.
bug
topic-reveal-type
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
Bug Report
reveal_locals() doesn't show module globals that are annotated with type information.
To Reproduce
from typing import List
global_var = [1, 2, 3]
global_var_annotated: List[int] = [1, 2, 3]
reveal_locals()
def foo():
local_var = [1, 2, 3]
local_var_annotated: List[int] = [1, 2, 3]
reveal_locals()
Expected Behavior
A note on the global_var_annotated variable:
note: global_var_annotated: builtins.list[builtins.int]
Actual Behavior
global_var_annotated is missing from the revealed types:
note: Revealed local types are:
note: global_var: builtins.list[builtins.int*]
note: Revealed local types are:
note: local_var: Any
note: local_var_annotated: builtins.list[builtins.int]
Your Environment
- mypy 0.931
- Python 3.7.7
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.
Research direction
Start by running the supplied Python reproduction with mypy and inspect the reveal_locals() handling for module-level annotated globals. Compare its output with the expected note for global_var_annotated; done when annotated module globals are included without regressing the existing local and unannotated global output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100