Cannot ignore type errors in multiline strings
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 20.6k
- フォーク
- 3.3k
- PR マージ指標
- PR 指標を取得中
説明
stringy = "foo"
f"""\
{stringy.nope()}
""" # type: ignore
(ignore that this is a true positive - my real code is much more complicated and is actually valid, the above is just a contrived example to show the core problem)
In Python 3.7 with mypy 0.782, it reports the error on the closing """ (if you remove the # type: ignore), so it picks up the ignore directive and all is well. In Python 3.8, it reports the error on the previous line. There's no way to add # type: ignore on that line, and adding it anywhere else has no effect.
In other cases it tends to report the error as being on the line with the opening """… I'm not sure why in this particular, contrived example it behaves differently. But either way, it's a major problem, since there's no practical workaround for this [in my much larger, real-world code]. It's blocking the upgrade to Python 3.8 for one of my major projects.
(the output from mypy w/ Python 3.8)
test.py:4: error: "str" has no attribute "nope"
Found 1 error in 1 file (checked 1 source file)
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
提供された test.py スニペットを Python 3.8 と mypy 0.782 で使用して報告を再現し、その後、診断の位置を Python 3.7 と比較する。複数行 f-string の診断と # type: ignore の処理を追跡する。閉じる三重引用符付き文字列にある ignore が報告されたエラーを一貫して抑制すれば完了とする。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100