Skip to content

Inline importing function from same module causes unresolved-import error #2596

@sid-kap

Description

@sid-kap

Summary

Importing the same module inline works:

def foo() -> int:
    return 1

def bar() -> int:
    import main
    return main.foo()

https://play.ty.dev/5e93575f-83a5-4186-bf04-0babd27364b1

But importing a function from the same module triggers an unresolved-import error:

def foo() -> int:
    return 1

def bar() -> int:
    from main import foo
    return foo()
Module `main` has no member `foo` (unresolved-import) [Ln 5, Col 22]

https://play.ty.dev/83b6a067-c32d-432e-a7da-f0eea1bdd6e2

I believe the second example should pass typechecking?

Version

ty 0.0.12 (Homebrew 2026-01-14)

Metadata

Metadata

Assignees

Labels

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

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions