Skip to content

UV settings not respected in pyproject.toml #1938

@Tayum

Description

@Tayum

Problem: Some uv settings, set in pyproject.toml, aren't respected, whereas some are.

Steps to reproduce:

# pyproject.toml
[tool.uv.sources]
pytest = { index = "pypi" }

[[tool.uv.index]]
name = "pypi"
url = "https://pypi.org/simple/"
explicit = true

[[tool.uv.index]]
name = "another"
url = "https://something.wrong"
default = true

[tool.hatch.envs.example]
installer = "uv"
dependencies = [
    "pytest",
]

Run command:

% hatch run example:true

Expected output: The command finishes successfully, as a package is found in https://pypi.org/simple/.

Actual output:

error: Failed to fetch: `https://something.wrong/pytest/`
  Caused by: Could not connect, are you offline?
  Caused by: Request failed after 3 retries
  Caused by: error sending request for url (https://something.wrong/pytest/)
  Caused by: client error (Connect)
  Caused by: dns error: failed to lookup address information: nodename nor servname provided, or not known
  Caused by: failed to lookup address information: nodename nor servname provided, or not known

In case default and explicit are swapped:

# pyproject.toml
[tool.uv.sources]
pytest = { index = "another" }

[[tool.uv.index]]
name = "pypi"
url = "https://pypi.org/simple/"
default = true

[[tool.uv.index]]
name = "another"
url = "https://something.wrong"
explicit = true

[tool.hatch.envs.example]
installer = "uv"
dependencies = [
    "pytest",
]

Then the command finishes successfully. It means that [[tool.uv.index]] seems to be respected, whereas [tool.uv.sources] is not.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions