Skip to content

Broken relative imports for almost-src layouts #1398

@Salamandar

Description

@Salamandar

Summary

Here's the project topology:

myproject/
├─ src/
│  ├─ __init__.py
│  ├─ utils.py
│  └─ something.py
├─ tests/
└─ pyproject.toml

with something.py importing like from .utils import utilityfunc.

ty doesn't like that at all. debugging gives:

2025-10-19T18:52:58.723460Z DEBUG ty_python_semantic::types::infer::builder: Relative module resolution `.utils` failed: too many leading dots
    at crates/ty_python_semantic/src/types/infer/builder.rs:5010 on ThreadId(2)
    in ty_project::check_file with file=file(Id(c00))
    in ty_project::Project::check

So i guess ty finds the src directory and thinks it's gone one time up too many.

Is there any way to support this project layout ?

(of course creating a subdir src/myproject or renaming src to myproject "fixes" the issue)

Version

ty 0.0.1-alpha.23 (5c51b84 2025-10-16)

Metadata

Metadata

Assignees

No one assigned

    Labels

    importsModule resolution, site-packages discovery, import-related diagnosticsquestionAsking for support or clarification

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions