-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
target-version
in ruff.toml
#119
Comments
In the future, Coherent OSS aims to deliver a "zero-config" project with configuration composable from various files in a special subdirectory (for configuration files only) in every downstream project repository. Since Ruff provides the convenience of automatic reading of I'm however only speaking for myself here, it's all up to @jaraco here. |
@bswck I agree with you, perhaps you should add your comment in astral-sh/ruff#10299. Note that the problem is two-fold:
|
First and foremost, thanks for raising this issue. I very much want to avoid providing the "minimum supported Python version" in more than one place. I've worked hard to remove it from Trove Classifiers and tox configs and other places. I'd like also to remove it from the GitHub actions if possible, though I don't think that's possible at this time. I'd like not to add yet another redundant indicator to ruff.toml. The canonical indicator is in the Requires-Python field of the project's metadata. I believe ruff's reliance on any configuration file from other tooling is misplaced. Ideally, ruff should instead load the "Requries-Python" metadata using standards-based tooling. I can see the desire to extract it from pyproject.toml, as that also has a standards basis. I would actually recommend against ruff (or other tooling) pulling from setup.cfg, as pyproject.toml is to be preferred. The most reliable and correct way for ruff to get the metadata from any PEP 517 backed project irrespective of their configuration is to use that API: __requires__ = ['build']
import build.util
print(build.util.project_wheel_metadata('.')['Requires-Python']) Unfortunately, that routine is potentially expensive, as, depending on the backend and the project, it likely requires downloading and installing all of the build dependencies and even building the project into a wheel before extracting the metadata. Some build backends and standards efforts are working on providing more efficient access to the metadata without having to conduct a full build, but the standard only provides for one set of build dependencies, so that aspect may always be heavy.
The short answer is yes. I'd like to move all projects to pyproject.toml. Although I have avoided moving configuration for non-build tooling, I do expect the pyproject.toml to be the best place to configure declarative project metadata. I just haven't had the time to make the leap. I've filed #121 to track. |
Understood. I'll track #121 for progress, but your target also relies on convincing the ruff authors to read |
I think I can make a good case. I'll plan to do that. |
In astral-sh/ruff#10299 (comment), I made the case for reading the core metadata instead of reading the declared metadata. In that same issue, I noticed that some have indicated that adding an |
I realized I don't have a good way to test. I've confirmed that adding |
According to the
target-version
documentation, ruff reads the target Python version fromproject.requires-python
inpyproject.toml
:Since this skeleton defines
requires-python
insetup.cfg
, not inpyproject.toml
, it is not picked up. Therefore, we must redefine the minimal Python version astarget-version
inruff.toml
. This brings the question, are you planning on moving fromsetup.cfg
topyproject.toml
? Alternatively, would it be possible to move therequires-python
fromsetup.cfg
topyproject.toml
?Additionally, ruff does not read
project.requires-python
frompyproject.toml
if aruff.toml
file exists. It is unclear at this point whether this is a bug or a feature:astral-sh/ruff#10299
The text was updated successfully, but these errors were encountered: