Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reveal_locals() doesn't show module globals that are annotated #12478

Open
johnburnett opened this issue Mar 28, 2022 · 4 comments
Open

reveal_locals() doesn't show module globals that are annotated #12478

johnburnett opened this issue Mar 28, 2022 · 4 comments
Labels
bug mypy got something wrong topic-reveal-type reveal_type() and reveal_locals()

Comments

@johnburnett
Copy link

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
@johnburnett johnburnett added the bug mypy got something wrong label Mar 28, 2022
@JelleZijlstra JelleZijlstra added the topic-reveal-type reveal_type() and reveal_locals() label Mar 28, 2022
@jhance
Copy link
Collaborator

jhance commented Mar 29, 2022

Why do you expect a global variable to appear in the output for reveal locals?

@JelleZijlstra
Copy link
Member

The fact that it shows global_var but not global_var_annotated seems like a bug though.

@jhance
Copy link
Collaborator

jhance commented Mar 29, 2022

Oh I see, I thought the complaint was about the second revealed local types not including it.

@johnburnett
Copy link
Author

johnburnett commented Mar 29, 2022

@jhance - the example "global_*" vars are locals to the module. And yep, @JelleZijlstra - correct, the missing annotated var feels like a bug?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong topic-reveal-type reveal_type() and reveal_locals()
Projects
None yet
Development

No branches or pull requests

3 participants