astral-sh / ruff

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

Support requires-python setting from PEP 723 #13446

Closed majutsushi closed 1 month ago

majutsushi commented 1 month ago

It would be really helpful for standalone scripts if Ruff would support reading the requires-pyton setting from the PEP 723 metadata. Standalone scripts usually don't have a separate project config file, but in some cases they may still want to configure the Python version that Ruff uses.

In my case I ran into this because I was using the zoneinfo module that was added to the standard library in 3.9, and I was surprised that Ruff sorted it under third-party imports (see also https://github.com/astral-sh/ruff/issues/6475 and https://github.com/astral-sh/ruff/issues/13354). So it would be great if Ruff could support the metadata comment block for that.

majutsushi commented 1 month ago

I just noticed that https://github.com/astral-sh/ruff/issues/10457 already exists, so I'll add a comment there instead.