astral-sh / ruff

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

Fixer for using typing_extensions for unsupported typing imports #13889

Open fzimmermann89 opened 2 hours ago

fzimmermann89 commented 2 hours ago

An automatic fix would be great if symbols are imported from typing that are not available at the lowest required python version but are available in typing_extensions, if typing_extensions is a dependency. This would fix the opposite issues of #7285 UP035.

dhruvmanila commented 2 hours ago

That's a neat idea although it'll require Ruff to know whether typing_extensions is a dependency of the project.

MichaReiser commented 2 hours ago

I'll merge this into https://github.com/astral-sh/ruff/issues/2501 which is a more general request to add "backporting" rules.

fzimmermann89 commented 2 hours ago

@MichaReiser But https://github.com/astral-sh/ruff/issues/2501 is also due to the much larger scope of transforming syntax a lot more complex and thus stuck...

MichaReiser commented 2 hours ago

We can keep it open but there remains the question where the rule should belong to. Naturally, it would fit into the pydowngrade category but we could consider adding it to Ruff.