Skip to content

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

Description

@5j9

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

Activity

  1. added theissue type on Nov 21, 2026
  2. YashVerma-code commented on Nov 22, 2026

    @YashVerma-code

    I've opened a #5719 PR for this, #claim

  3. github-actions commented on Nov 22, 2026

    @github-actions

    @YashVerma-code you've claimed this issue — it's now assigned to you. Thanks for picking it up! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions