astral-sh / ruff

An extremely fast Python linter and code formatter, written in Rust.
https://docs.astral.sh/ruff
MIT License
31.78k stars 1.07k forks source link

UP035 (deprecated-import) for backports.strenum #8102

Closed amartani closed 11 months ago

amartani commented 11 months ago

https://pypi.org/project/backports.strenum/ implements a backport of Python 3.11's enum.StrEnum as backports.strenum.StrEnum. It would be nice if UP035 (deprecated-import) added support for replacing it with the original version when targeting 3.11+.

Note that the package instructions already suggests using:

if sys.version_info >= (3, 11):
    from enum import StrEnum
else:
    from backports.strenum import StrEnum

But if someone is not using the conditional import, it would be good for UP035 to clean it up.

Tested on ruff v0.1.1 - https://play.ruff.rs/c973b82b-0107-469b-9b10-9196353b8901

charliermarsh commented 11 months ago

Seems reasonable!