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

Abierto
#5,693 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
68/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
python, rust
Área
testing-qa

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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

Lenguaje dominante
Rust
Estrellas
7.2k
Forks
578
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de facebook/pyrefly

Todos los issues de facebook/pyrefly

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.