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

Đang mở
#5,693 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
68/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python, rust
Lĩnh vực
testing-qa

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Ngôn ngữ chính
Rust
Star
7.2k
Fork
578
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của facebook/pyrefly

Tất cả issue của facebook/pyrefly

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.