Deprecation warnings are not emitted when the deprecated decorator is imported with an alias

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

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

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
68/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python, rust
領域
testing-qa

調査の方向性

Start by tracing how Pyrefly recognizes the standard library's warnings.deprecated decorator and how imported names are resolved; the issue does not name source files or tests. Reproduce the behavior with the provided scratch.py example and uvx pyrefly check --min-severity warn. Done means the aliased import produces the deprecation warning for old_func() while the unaliased case still works.

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

説明

typechecking
Describe the Bug

Pyrefly does not emit deprecated diagnostics when the deprecated decorator from the standard library's warnings module is imported using an alias.

The same code produces the expected warning when the decorator is imported without an alias.

Steps to reproduce

Create a file named scratch.py:

from warnings import deprecated as _deprecated

@_deprecated("Use new_func instead")
def old_func() -> None:
    pass

old_func()

Run:

uvx pyrefly check --min-severity warn
Expected behavior

Pyrefly should report a deprecation warning for the call to old_func().

Actual behavior

No deprecation warning is reported.

Additional information

Removing the alias makes the warning appear:

from warnings import deprecated

@deprecated("Use new_func instead")
def old_func() -> None:
    pass

old_func()

Tested with Pyrefly 1.5.0.

Sandbox Link

https://pyrefly.org/sandbox/?project=v2.jZRNDsIgEIWvMmkXuJKFu57CjStJGiKkmhgggnp934CGNjWkS_5mhvnevKZlcjIYQp15G1CxRu3cpbEu83TO1jvVnSANZ98jqxmgYrLaqA5gWBz-bvLBSiCFiXKzC9QDTkCjrBnoXHOgl2sEPR3LBn1_A_MBu-kJiwOTvXI93M3SNaUQByl_z_1jktZJ4y9RLl5IYrXpl75l41yGI58lExH2P_vDJvaioBct8oJZ4EYT5gc

(Only applicable for extension issues) IDE Information

No response

主要言語
Rust
スター
7.2k
フォーク
578
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

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

facebook/pyrefly のほかの issue

facebook/pyrefly の issue をすべて見る

似ている issue

Rust の issue をもっと見る

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

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