Skip to content

Module level __getattr__ not respected #943

@pelme

Description

@pelme

Summary

Defining a module level __getattr__ is not picked up by ty: https://play.ty.dev/d17f33d6-87ec-4305-b390-9a15f9d88e7c

ty:

❯ ty check --output-format=concise main.py
WARN ty is pre-release software and not ready for production use. Expect to encounter bugs, missing features, and fatal errors.
main.py:1:23: error[unresolved-import] Module `upper` has no member `whatever`
main.py:3:1: warning[undefined-reveal] `reveal_type` used without importing it
main.py:3:13: info[revealed-type] Revealed type: `str`
main.py:4:1: warning[undefined-reveal] `reveal_type` used without importing it
main.py:4:13: info[revealed-type] Revealed type: `Unknown`
Found 5 diagnostics

mypy and pyright supports this:

❯ mypy main.py
main.py:3: note: Revealed type is "builtins.str"
main.py:4: note: Revealed type is "builtins.str"
Success: no issues found in 1 source file

❯ pyright main.py
/private/tmp/stuff.XZqSg2LO0/main.py
  /private/tmp/stuff.XZqSg2LO0/main.py:3:13 - information: Type of "hi" is "str"
  /private/tmp/stuff.XZqSg2LO0/main.py:4:13 - information: Type of "whatever" is "str"
0 errors, 0 warnings, 2 informations

Version

ty 0.0.1-alpha.16 (c452e53 2025-07-25)

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedContributions especially welcomeruntime 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