Skip to content

Support uv workspaces #1060

@cospectrum

Description

@cospectrum

Environment

  • deptry version: 0.23.0
  • Python version: 3.10.16
  • Operating system (e.g. Ubuntu 22.04, Windows 11): macos

Describe the issue

uv run deptry . for uv-workspace gives bad results that on location.

Minimal way to reproduce the issue

project structure:

root/
  pyproject.toml
  uv.lock
  packages/
    first/
      pyproject.toml
      src/
        first/
          __init__.py
          ...
    second/
      pyproject.toml
      src/
        second/
          __init__.py

root pyproject.toml:

[project]
name = "uv-workspace"
version = "0.1.0"
description = "uv workspace"
readme = "README.md"
requires-python = ">=3.10"
dependencies = []

[tool.uv.workspace]
members = ["packages/*"]

first pyproject.toml:

[project]
name = "first"
version = "0.1.0"
description = "first"
readme = "README.md"
requires-python = ">=3.10"
dependencies = ["second", "b"] # note: there is no "a", but it is imported in the `src/first/*` files for more complex behavior

[tool.uv.sources]
second = { workspace = true }

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

second pyproject.toml:

[project]
name = "second"
version = "0.1.0"
description = "second"
readme = "README.md"
requires-python = ">=3.10"
dependencies = []

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

root/packages/first/src/first/*.py files contain imports for the following modules:
second, a, b and first (import from itself).

uv run deptry . inside the root dir warns about the following depndencies of the first module: b, first, second.
uv run deptry . inside the first dir warns about the following depndencies of the first module: a, first.

Expected behavior

  1. each leaf package must be analyzed as if deptry was running from its root.
  2. therefore, deptry from the root package should warn about a dependency of thefirst project.
  3. deptry should not warn about "import from itself".

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions