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.

貢獻者指南