python / python/mypy

`--disallow-untyped-calls` reports errors in untyped functions

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

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

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

説明

Bug Report

Using --disallow-untyped-calls and --check-untyped-defs results in errors about calling untyped functions in a typed context, even when calling from an untyped function.

To Reproduce

Test case:

[case testDisallowUntypedCallsFromUntypedFunction]
# flags: --disallow-untyped-calls --check-untyped-defs

def f(x):
    pass

def g(y):
    f(y)

Expected Behavior

Either:

  • the documentation and the error message should be updated to specify that --disallow-untyped-calls disallows all calls to untyped functions, regardless of whether the current function has type annotations, or
  • the above code shouldn't produce any errors

Actual Behavior

The call to f in the above example produces the error "Call to untyped function "f" in typed context".

Your Environment

See https://mypy-play.net/?mypy=latest&python=3.10&flags=check-untyped-defs%2Cdisallow-untyped-calls&gist=3350fe27968b29dabc5ef1e207d008ce to reproduce.

This came up in #12901 (specifically the mypy_primer diff had an error here)

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

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

はじめの一歩

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

調査の方向性

testDisallowUntypedCallsFromUntypedFunction という名前のテストケースから始め、--disallow-untyped-calls と --check-untyped-defs を使って再現します。g 内の f の呼び出しがどのように分類されるかを追跡し、そのうえで、意図された修正がドキュメントと文言の更新なのか、それともテストでエラーが発生しなくなるように動作を変更することなのかを判断します。

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

評価

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

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

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