No error when attempting to use property object as that property's type
オープン
まだ誰も着手していません。
priority-2-low
topic-descriptors
topic-named-tuple
topic-runtime-semantics
- 主要言語
- Python
- スター
- 20.6k
- フォーク
- 3.3k
- PR マージ指標
- PR 指標を取得中
説明
- Are you reporting a bug, or opening a feature request? Bug
- Please insert below the code you are checking with mypy,
or a mock-up repro if the source is private. We would appreciate
if you try to simplify your case to a minimal repro.
from typing import NamedTuple
class C(NamedTuple):
a: int = 1
print(C.a * 2)
- What is the actual behavior/output?
mypy a.py produces no output.
- What is the behavior/output you expect?
An error at C.a * 2, as it will cause an error at runtime: TypeError: unsupported operand type(s) for *: 'property' and 'int'
- What are the versions of mypy and Python you are using?
python --version: 3.7.2
mypy --version: 0.660+dev.97d7760dca6d95806a97b02992ae88a082898a0e
Do you see the same issue after installing mypy from Git master? Yes
- What are the mypy flags you are using? (For example --strict-optional) None
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、報告された例を使って mypy a.py を実行し、出力がない一方で Python は指定された TypeError を発生させることを確認します。mypy が NamedTuple のプロパティアクセスと算術式をどのように処理するかを追跡します。このケースで mypy が C.a * 2 に対してエラーを報告すれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 45/100