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

Hatch environment nested 2+ levels deep does not inherit ancestor env-vars #1911

Open
valentinoli opened this issue Feb 12, 2025 · 0 comments

Comments

@valentinoli
Copy link

valentinoli commented Feb 12, 2025

I have the following in my pyproject.toml:

[tool.hatch.envs.default]
installer = "uv"

[tool.hatch.envs.default.env-vars]
UV_INDEX_MY_INDEX_PASSWORD = "{env:UV_INDEX_MY_INDEX_PASSWORD :{env:SYSTEM_ACCESS_TOKEN:}}"

[tool.hatch.envs.hatch-static-analysis]
config-path = "ruff_defaults.toml"

[tool.hatch.envs.lint]
template = "hatch-static-analysis"

[tool.hatch.envs.lint.scripts]
run = ["hatch fmt --check"]

I am using a CI pipeline template that runs hatch run lint:run and I am not in a position to change this template to instead just use hatch fmt --check directly (which relies on the hatch-static-analysis environment). As you can see, the lint environment inherits from hatch-static-analysis, so it is two levels down from the default environment where I define the UV_INDEX_MY_INDEX_PASSWORD used to authenticate to the Python package index with uv. Unfortunately, this environment variable is not accessible in the lint environment so I must duplicate the env-vars section there to make it work but I do not want to do that.

Is there a way around this?

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

No branches or pull requests

1 participant