NamedTuple single line declaration gives error "Too many arguments for NamedTuple() [misc]
オープン
まだ誰も着手していません。
bug
semantic-analyzer
topic-named-tuple
- 主要言語
- Python
- スター
- 20.6k
- フォーク
- 3.3k
- PR マージ指標
- PR 指標を取得中
説明
Bug Report
typing.NamedTuple one line declaration gives incorrect error
To Reproduce
# test.py
from typing import NamedTuple
ExampleClass = NamedTuple('ExampleClass', test_id=str, timestamp=str)
mypy --show-error-codes test.py
test.py:[line-no]: error: Too many arguments for NamedTuple() [misc]
Expected Behavior
mypy doesn't give this error
given the above syntax is valid python and works fine, I would expect it to not throw an error, like the following old structure declaration does not, which is labeled as "back-ward compatible usage" in the official doc
ExampleClass = NamedTuple('ExampleClass', [(test_id, str), (timestamp, str)])
Actual Behavior
error: Too many arguments for NamedTuple() [misc]
Your Environment
mypy --version
mypy 0.910
python --version
3.8.10
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、報告された test.py の例を mypy --show-error-codes で実行し、NamedTuple 呼び出しの処理を調査します。キーワードベースの 1 行宣言で誤って "Too many arguments for NamedTuple()" エラーが生成されなくなり、既存のリストベースの宣言は引き続き受け入れられれば完了です。リポジトリ内のテストの場所を特定できた場合は、回帰テストを追加してください。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- devtools
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 45/100