Skip to content

__file__ import typed as str | None #860

@sinon

Description

@sinon

Summary

import typing
import os 
from module import __file__ as module_path

typing.reveal_type(module_path). # str | None
os.path.abspath(module_path) # No overload of function `abspath` matches arguments

https://play.ty.dev/4dd59d9f-5dbe-433e-b370-67bbd5575fb2

mypy and pyright both detect the successful import and type the value as str

Version

ty 0.0.1-alpha.15 (0369a35 2025-07-18)

Metadata

Metadata

Assignees

No one assigned

    Labels

    runtime semanticsAccurate modeling of how Python's semantics work at runtime

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions