Skip to content

Project dependencies not detected when using uv run --with ty #320

@zanieb

Description

@zanieb

Steps to reproduce (CPython 3.13.2, uv 0.7.3, ty 0.0.0-alpha.8):

uv init tmp
cd tmp
uv add httpx
echo 'import httpx' >> main.py
uv run --with ty ty check

ty says:

error[unresolved-import]: Cannot resolve imported module `httpx`

it works fine if you uv add ty, but doesn't work when you uv run --with ty ty check. uv run --with mypy mypy . works fine and finds the import.

uv run --with ty ty check --verbose --verbose

2025-05-11 12:51:51.281544701 WARN ty is pre-release software and not ready for production use. Expect to encounter bugs, missing features, and fatal errors.
2025-05-11 12:51:51.281577281 DEBUG Version: 0.0.0-alpha.8
2025-05-11 12:51:51.281602471 DEBUG Architecture: x86_64, OS: linux, case-sensitive: case-sensitive
2025-05-11 12:51:51.281703641 DEBUG Searching for a project in '/home/collin/tmp'
2025-05-11 12:51:51.281806121 DEBUG Resolving requires-python constraint: `>=3.13`
2025-05-11 12:51:51.281832661 DEBUG Resolved requires-python constraint to: 3.13
2025-05-11 12:51:51.281854762 DEBUG Project without `tool.ty` section: '/home/collin/tmp'
2025-05-11 12:51:51.281868452 DEBUG Searching for a user-level configuration at `/home/collin/.config/ty/ty.toml`
2025-05-11 12:51:51.281893422 INFO Defaulting to python-platform `linux`
2025-05-11 12:51:51.281917742 INFO Python version: Python 3.13, platform: linux
2025-05-11 12:51:51.281930492 DEBUG Adding first-party search path '/home/collin/tmp'
2025-05-11 12:51:51.281947742 DEBUG Using vendored stdlib
2025-05-11 12:51:51.282668282 DEBUG Discovering site-packages paths from sys-prefix `/home/collin/.cache/uv/archive-v0/aA7ze3NeJgM8fooLQjSvY` (`VIRTUAL_ENV` environment variable')
2025-05-11 12:51:51.282701342 DEBUG Attempting to parse virtual environment metadata at '/home/collin/.cache/uv/archive-v0/aA7ze3NeJgM8fooLQjSvY/pyvenv.cfg'
2025-05-11 12:51:51.282745112 DEBUG Searching for site-packages directory in `sys.prefix` path `/home/collin/.cache/uv/archive-v0/aA7ze3NeJgM8fooLQjSvY`
2025-05-11 12:51:51.282753712 DEBUG Resolved site-packages directories for this virtual environment are: ["/home/collin/.cache/uv/archive-v0/aA7ze3NeJgM8fooLQjSvY/lib/python3.13/site-packages"]
2025-05-11 12:51:51.282758592 DEBUG Adding site-packages search path '/home/collin/.cache/uv/archive-v0/aA7ze3NeJgM8fooLQjSvY/lib/python3.13/site-packages'
2025-05-11 12:51:51.282942792 DEBUG Starting main loop
Checking ------------------------------------------------------------ 0/0 files                                                                                                    2025-05-11 12:51:51.283013262 DEBUG Waiting for next main loop message.
2025-05-11 12:51:51.283144902 DEBUG Checking project 'tmp'
2025-05-11 12:51:51.285666824 INFO Indexed 1 file(s)
Checking ------------------------------------------------------------ 0/1 files                                                                                                    2025-05-11 12:51:51.286172246 DEBUG Checking file '/home/collin/tmp/main.py'
2025-05-11 12:51:51.316921754 DEBUG Resolving dynamic module resolution paths
2025-05-11 12:51:51.317122364 DEBUG Module `httpx` not found in search paths
error[unresolved-import]: Cannot resolve imported module `httpx`

Originally posted by @collinanderson in #171

Metadata

Metadata

Assignees

No one assigned

    Labels

    importsModule resolution, site-packages discovery, import-related diagnosticsuv

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions