python / python/typing

Class-qualified annotation expressions

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

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

topic: documentation
主要言語
Python
スター
1.8k
フォーク
302
平均マージ
23時間
マージ済み PR(30日)
8

説明

The wonderfully useful specification of type annotation expressions describes what kinds of expressions are valid type annotations.

I believe the spec does not include a case which type checkers support, although as we will see this comes down to semantics :)

class A:
    class B:
        pass

x: A.B = A.B()

The A.B annotation seems to fall under the name rule:

| name
      (where name must refer to a valid in-scope class,
       type alias, or TypeVar)

The spec helpfully continues:

Any leaf denoted as name may also be a qualified name (i.e., module '.' name or package '.' module '.' name, with any level of nesting).

The concept of a "qualified name" occurs only in this section, and the parenthetical explanation serves as it's most precise definition, as far as I can tell.

Should we extend the definition of "qualified name" to also include class members? Or maybe I should read the class as a "module" or a "package" and the existing definition suffices?

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

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

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

調査の方向性

型およびアノテーション式の仕様、特に namequalified name の定義から始め、issue の A.B の例と比較してください。既存の型チェッカーがクラス修飾アノテーションをどのように解釈するかを確認してください。仕様にクラスメンバーを含めるかどうかと、例をどのように扱うかが明確に記載されていれば完了です。

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

評価

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

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

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