python / python/mypy

TypeGuard may spuriously narrow Any -> object

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

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

bug topic-typeguard-typeis
主要言語
Python
スター
20.6k
フォーク
3.3k
PR マージ指標
PR 指標を取得中

説明

I haven't had time to fully reduce this, but in the Sphinx code at https://github.com/sphinx-doc/sphinx/blob/1d4c414319598320f95eed245e4a2f9ad3e5a668/sphinx/ext/coverage.py#L218, the TypeGuards introduced by python/typeshed#5473 lead to an incorrect error:

+ sphinx/ext/coverage.py: note: In member "build_py_coverage" of class "CoverageBuilder":
+ sphinx/ext/coverage.py:218:51: error: Item "object" of "Union[object, object]" has no attribute "__doc__"

Seems like some bad interaction with the negative case for the TypeGuards produced by ismethod and isfunction a few lines up.

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

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

はじめの一歩

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

調査の方向性

sphinx/ext/coverage.py の 218 行目付近から始め、ismethod と isfunction の TypeGuards に関して報告されたエラーを再現します。Sphinx のケースを Any の narrowing に関する焦点を絞った例に縮小します。doc への有効なアクセスで object-member エラーが報告されなくなれば完了です。

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

評価

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

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

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