Skip to content

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

@johnburnett

Description

@johnburnett

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrongtopic-reveal-typereveal_type() and reveal_locals()

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions