Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

better static checks on initializing CheckedDict variables with dictionary literals

オープン
#60 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
42/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
python
領域
compilers

調査の方向性

cinder/3.8/Lib/test/test_compiler/test_static/tests.py から始め、特に test_compile_checked_dict_with_annotation_wrong_key_type と、値の型が誤っている場合の類似したテストを確認してください。これらのテストを実行し、辞書リテラルが代入された CheckedDict アノテーションに対する静的チェッカーの動作を追跡してください。キーの式が T1 に対して、値が T2 に対してチェックされ、キーの不一致が直接報告されれば完了です。

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

説明

sp-adoption staticpython

a4a71ae
2021-12-20

What program did you run?
from __static__ import CheckedDict

class B: pass

def testfunc():
x: CheckedDict[B, int] = {object():42}
return x

This program is found in cinder/3.8/Lib/test/test_compiler/test_static/tests.py. This test is labeled test_compile_checked_dict_with_annotation_wrong_key_type. There is a similar test labeled test_compile_checked_dict_with_annotation_wrong_value_type.

What happened?
compiler.errors.TypedSyntaxError: type mismatch: Exact[chkdict[object, Literal[42]]] cannot be assigned to Exact[chkdict[__main__.B, int]]
What should have happened?

We expected a compile-time error complaining that object cannot be assigned to B. In general, we expect that everytime the type checker sees x: CheckedDict[T1, T2] = { e1: e2, ... }, it checks every key expression e1 against T1, and every e2 against T2.

主要言語
Python
スター
3.8k
フォーク
139
PR マージ指標
30日以内にマージされた PR はありません

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

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

はじめの一歩

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

facebookincubator/MetaPython のほかの issue

facebookincubator/MetaPython の issue をすべて見る

似ている issue

Python の issue をもっと見る

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

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