Skip to content

type: type = … fails with deferred annotations #899

@WyattBlue

Description

@WyattBlue
# test.py
from __future__ import annotations


class MyClass:
    type: type = str

Running:

ty check test.py

Causes a panic:

ty check test.py
WARN ty is pre-release software and not ready for production use. Expect to encounter bugs, missing features, and fatal errors.
error[panic]: Panicked at /Users/runner/.cargo/git/checkouts/salsa-e6f3bb7c2a062968/dba66f1/src/function/execute.rs:212:25 when checking `/Users/wyattblue/projects/auto-editor/test.py`: `infer_definition_types(Id(1401)): execute: too many cycle iterations`
info: This indicates a bug in ty.
info: If you could open an issue at https://github.com/astral-sh/ty/issues/new?title=%5Bpanic%5D, we'd be very appreciative!
info: Platform: macos aarch64
info: Version: 0.0.1-alpha.16 (c452e53a0 2025-07-25)
info: Args: ["ty", "check", "test.py"]
info: run with `RUST_BACKTRACE=1` environment variable to show the full backtrace information
info: query stacktrace:
   0: infer_scope_types(Id(1001))
             at crates/ty_python_semantic/src/types/infer.rs:134
   1: check_file_impl(Id(c00))
             at crates/ty_project/src/lib.rs:514


Found 1 diagnostic
WARN A fatal error occurred while checking some files. Not all project files were analyzed. See the diagnostics list above for details.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfatala fatal error (panic or crash)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions