python / python/mypy

--disallow-untyped-calls allows calling values with Any type

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

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

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

説明

The calls to f and ff below aren't rejected when using --disallow-untyped-calls, even though I believe that they should be:

from typing import Any

from non_existent import f  # type: ignore  # Not in the build

def g(): pass

def h() -> None:
    g(asdf=1)  # Error: Call to untyped function "g" in typed context
    f(asdf=1)  # No error reported, but this is untyped
    ff: Any
    ff()  # No error reported, and again this in untyped

At the very least the first call should probably be caught. If non_existent gets added in the build with no type annotations, it would start generating errors. However, I'd expect that adding a module to the build should result in fewer Any-related errors, not more.

Marking this a high priority since I've been bit by this twice in production code.

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

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

はじめの一歩

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

調査の方向性

--disallow-untyped-calls を指定して issue の Python 例を再現し、その後、import された値および明示的に Any 型が付けられた値を介した呼び出しがどのようにチェックされるかを追跡する。f と ff への呼び出しが拒否され、g に対する既存の診断が変更されなければ完了とする。payload には、開始時に使用するソースファイルもテストも指定されていない。

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

評価

技術スタック
python
領域
compilers, devtools
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
39/100

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

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