`reveal_locals` is hella inconsistent / top level variables not listed / narrowed type inconsistent with `reveal_type`
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
a: int
b = 1
if isinstance(a, bool):
reveal_locals() # "b: int", I would expect "a: bool, b: int"
reveal_type(a) # "a: bool" ✔
def foo(a: int) -> None:
b: int
reveal_locals() # "a: int, b: int", this is correct, but inconsistent with top level
reveal_type(a)
a: int = 1
reveal_locals() # nothing 😥
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 locating the implementation and tests for reveal_locals(), then compare its handling of module and function scopes with reveal_type(). Done means the examples consistently include narrowed a values and initialized top-level variables in the reveal_locals() output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100