Skip to content

silence import resolution errors from an existing compiled extension module #715

@Stamppot82

Description

@Stamppot82

Summary

Environment: ty v0.0.1a12, Python 3.12, macOS, uv project

Problem: ty check reports unresolved-import errors for Cython extensions compiled to .so files, despite the imports working correctly at runtime.

Console Output:

error[unresolved-import]: Cannot resolve imported module `.math_utils`
 --> src/__init__.py:5:7
  |
5 | from .math_utils import add
  |       ^^^^^^^^^^

Project Structure:

src/
├── __init__.py
├── math_utils.pyx                    # Cython source
└── math_utils.cpython-312-darwin.so  # Compiled extension (exists)

Issue: ty only looks for .py files but not compiled .so extensions. The import from .math_utils import ... fails because ty cannot find a [math_utils.py]

Expected: ty should resolve imports from compiled Cython extensions when:

A .pyx source file exists
A corresponding .so file is present
The package is properly built/installed

Impact:
False positives make ty unusable for projects using Cython extensions, which are common in scientific Python, performance-critical libraries, and hybrid codebases.

Workaround: None effective (stub files don't work for dynamic imports from compiled extensions).

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions