python / python/mypy

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

オープン
#12,478 コメント 4 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

bug topic-reveal-type
主要言語
Python
スター
20.6k
フォーク
3.3k
PR マージ指標
PR 指標を取得中

説明

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

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、提供された Python 再現コードを mypy で実行し、モジュールレベルのアノテーション付きグローバル変数に対する reveal_locals() の処理を調べます。その出力を global_var_annotated に対する期待される注記と比較します。アノテーション付きのモジュールグローバルが含まれ、既存のローカル変数およびアノテーションなしのグローバル変数の出力にリグレッションがないことを確認できれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
devtools
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
42/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。