questions about CheckedDict and unknown types

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

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

評価

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

調査の方向性

まず、参照されている static Python のコミットを使って issue の 2 つの例を再現し、issue 59 に記載されている期待される動作と比較します。アノテーションと CheckedDict コンストラクター呼び出しにおける未知のジェネリック型の処理を追跡します。両方の形式が受け入れられ、コンストラクターの結果が CheckedDict[str, object] と互換性を持てば完了です。

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

説明

sp-ux staticpython

IIUC (based on issue 59), types like CheckedDict[str, Set[str]] where SP doesn't understand part of the type should:

  1. be allowed, and
  2. turn into CheckedDict[str, object]

But neither seems to work. (I'm running SP commit 1b01cd886.)

First, this type doesn't work except in a constructor call. Other type annotations give an error:

from __static__ import CheckedDict
from typing import Set

def f(dd: CheckedDict[int, Set[str]]):
  return

#     def f(dd: CheckedDict[int, Set[str]]):
# TypeError: expected type or Optional[T] for generic argument

Second, the constructor call gives a chkdict[str, dynamic] instead of replacing the unknown type with object:

from __static__ import CheckedDict
from typing import Set

d0: CheckedDict[str, dynamic] = CheckedDict[str, Set[str]]({})
# OK
d1: CheckedDict[str, object] = CheckedDict[str, Set[str]]({})
# compiler.errors.TypedSyntaxError: type mismatch: chkdict[str, dynamic] cannot be assigned to chkdict[str, object]

Are these problems?

主要言語
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 を短くまとめたダイジェスト。