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

未关闭
#5,693 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
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. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

facebook/pyrefly 的其他 Issue

查看 facebook/pyrefly 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。