Skip to content
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

Inheriting [tool.uv] section from root-level pyproject.toml when desired #11070

Open
uwu-420 opened this issue Jan 29, 2025 · 2 comments
Open
Labels
configuration Settings and such enhancement New feature or improvement to existing functionality

Comments

@uwu-420
Copy link

uwu-420 commented Jan 29, 2025

Summary

Hi all, thanks for making uv!

I'm trying to make a monorepo with uv and I'd love to do some base uv configuration in the root level pyproject.toml. Things that are most likely to be the same for all packages, e.g. package indices. But I'm not using workspaces because the packages will have conflicting dependencies. This is also listed as a reason in the docs, see https://docs.astral.sh/uv/concepts/projects/workspaces/#when-not-to-use-workspaces But some packages will have some custom uv config in [tool.uv] in pyproject.toml but I noticed that this will cause the package to ignore everything set in [tool.uv] by the root pyproject.toml. I suppose this is intentional, but I could imagine my use case being relevant as well.

After all, I saw that ruff offers some explicit opt-in to inherit from some other config, see https://docs.astral.sh/ruff/settings/#extend which is really good for my use case! (I wish pyright and pytest would make it as easy... edit: pyright actually has an extends option, see here. pytest does not prioritize that as of now, see here)

Relatedly, there already seems to be some config merging logic https://docs.astral.sh/uv/configuration/files/ but it's only for uv.toml user/system-level files.

Example

Not exactly sure about the exact design of it but having this

# ./pyproject.toml
[tool.uv]
required-version = ">=0.5.25"

and

# ./sub/pyproject.toml
[tool.uv]
environments = ["sys_platform == 'linux'"]

it would be cool to have some way to let the ./sub/pyproject.toml inherit the required-version from ./pyproject.toml.

Maybe like ruff does it

# ./sub/pyproject.toml
[tool.uv]
extend = "../pyproject.toml"
environments = ["sys_platform == 'linux'"]
@uwu-420 uwu-420 added the enhancement New feature or improvement to existing functionality label Jan 29, 2025
@matthewadams
Copy link

You might be interested in #10960

@charliermarsh charliermarsh added the configuration Settings and such label Jan 30, 2025
@charliermarsh
Copy link
Member

I think we're somewhat unlikely to do this, but I understand the problem you're facing. I don't think we'd do the same thing in Ruff if we were to re-implement it today. The inheritance causes a lot of complexity and confusion for users. We do support inheritance of user- and system-level settings (e.g., ~/.config/uv/uv.toml as in https://docs.astral.sh/uv/configuration/files/ -- that gets combined with your pyproject.toml), so that's one option, but it doesn't help with sharing across a team.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
configuration Settings and such enhancement New feature or improvement to existing functionality
Projects
None yet
Development

No branches or pull requests

3 participants