Skip to content

Centralize configuration in pyproject.toml #5728

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

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

wisp3rwind
Copy link
Member

Most things can be configured in pyproject.toml. We were already using that in some cases (e.g. ruff). This PR compeletes this and removes setup.cfg entirely.

Additionally, this moves some entries in pyproject.toml from tool-specific sections (namely poetry) to general sections.

Draft because I want some CI feedback, and because it should also be possible to express dependencies in the general rather than poetry-specific format. (Which would for example enable the usage of uv, which is way faster.)

The individual commits in the PR should be easy to review.

@snejus
Copy link
Member

snejus commented Apr 15, 2025

I tend to keep project / dependencies specification separately from linters configuration. This way, seeing a change in pyproject.toml my brain instantly associates it with an update to the dependencies or the package; same applies to setup.cfg.

On the other hand, seeing that ruff does not support setup.cfg, and having to choose between ruff.toml and pyproject.toml for its config, I probably lean towards the latter.

And now for the sake of consistency, I guess, we can move all linters config to pyproject.toml, so I'm fine with this change.

@wisp3rwind
Copy link
Member Author

I tend to keep project / dependencies specification separately from linters configuration. This way, seeing a change in pyproject.toml my brain instantly associates it with an update to the dependencies or the package; same applies to setup.cfg.

On the other hand, seeing that ruff does not support setup.cfg, and having to choose between ruff.toml and pyproject.toml for its config, I probably lean towards the latter.

And now for the sake of consistency, I guess, we can move all linters config to pyproject.toml, so I'm fine with this change.

I see your point: It would be nice if there were a clear separation into two files: a package manifest and a file for tooling configuration. However, as of now, both are mixed up already (with ruff, poe, poetry config in pyproject.toml).

I came here originally because I wanted to run tests with a uv-managed virtual environment, which would require a dependency specification that uv can read. This should be possible (as mentioned above) by using project.dependencies key (and related ones) in pyproject.toml. I've been working on that locally, but not yet pushed it to this PR. Then I got distracted into checking out what kind of information can be specified in pyproject.toml these days, which is how the above came about. That said, I'd argue that something like the fourth commit should go in, but I don't feel as strongly about the first three commits.

Related: https://stackoverflow.com/a/56523197/3451198

@wisp3rwind wisp3rwind force-pushed the modernize-config branch 2 times, most recently from 6d95c0f to e363624 Compare April 15, 2025 13:00
@wisp3rwind
Copy link
Member Author

wisp3rwind commented Apr 15, 2025

I came here originally because I wanted to run tests with a uv-managed virtual environment, which would require a dependency specification that uv can read. This should be possible (as mentioned above) by using project.dependencies key (and related ones) in pyproject.toml. I've been working on that locally, but not yet pushed it to this PR.

Turns out that it's still a little early to achieve this: python-poetry/poetry#9751 (uv does support dependency-groups already).

this is not yet fully supported by poetry, however, which can't parse
dependency-groups at this time (uv can)
This was referenced Apr 20, 2025
wisp3rwind added a commit that referenced this pull request Apr 20, 2025
which added some mypy config to pyproject.toml, leading to mypy ignoring
setup.cfg
 (this shows up in CI output for #5701, but is not very visible
since we currently ignore mypy errors)

Related: #5728
@citelao
Copy link
Contributor

citelao commented May 25, 2025

I've been working with the poetry folks to get dependency-groups working, but it's taking some time.

In the meantime, a bit off-topic, but as someone who prefers uv, I've been using poetry "via" uv:

# The latest version of poetry is unsupported:
# uv tool install poetry --with poetry-plugin-shell
# (^ if you already ran that, run `uv tool uninstall poetry`)
uv tool install [email protected]
uv tool install poethepoet

poetry install

# poetry shell, poe test, ...

EDIT: updated to use a supported version of poetry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants