astral-sh/ruff

Split UP035 (deprecated-import) for aliases

Open

#7,436 创建于 2023年9月16日

在 GitHub 查看
 (3 评论) (0 反应) (0 负责人)Rust (2,088 fork)batch import
help wantedrule

仓库指标

Star
 (47,527 star)
PR 合并指标
 (平均合并 3天 8小时) (30 天内合并 573 个 PR)

描述

I'd like to request the deprecated-import rule be split in two. Currently UP035 flags two different kinds of deprecations:

  • Names that have been moved, with a deprecated alias. Examples:
    • collections.* => collections.abc.*
    • {pipes => shlex}.quote
  • Types that are deprecated, considered equivalent by type checkers, but are different runtime values.
    • This is everything in the typing, typing_extensions and mypy_extensions modules.

For the former group, fixing them is significantly safer, since the only visible side-effects would be that a module wasn't imported (in the case of pipes), and a lack of a DeprecationWarning. It'd be rare for code to depend on those side-effects. The latter group can potentially be an unsafe change if something tries to observe the types directly at runtime though.

Ultimately I'd like to be able to autofix the moved names, whilst being able to separately flag (with a suggested fix) the typing changes that would be observable at runtime.

贡献者指南