SIGN IN SIGN UP
astral-sh / ruff UNCLAIMED

An extremely fast Python linter and code formatter, written in Rust.

0 0 35 Rust

[ty] Avoid panic for deferred dataclass field annotations (#25444)

## Summary

I fixed https://github.com/astral-sh/ty/issues/3493 in
https://github.com/astral-sh/ruff/pull/25249, but missed the case of
deferred evaluation for annotations... For deferred evaluation, when we
then checked whether that field was a descriptor,
`class_member_with_policy` attempted meta-type lookup on the cycle
marker itself and panicked.

E.g., on Python 3.14, where annotations are deferred by default:

```python
from dataclasses import InitVar, dataclass
from ty_extensions import Top

@dataclass
class C:
    a: Top[int]
    int: InitVar[int] = 0

C()
```

We now apply the materialized divergent fallback before class-member
lookup, consistent with the other lookup and descriptor operations. (The
example reports the expected missing argument for `a` instead of
panicking, and is covered under Python 3.14.)

Closes https://github.com/astral-sh/ty/issues/3493.
C
Charlie Marsh committed
ae44d57db5ffcf010fd2c685a4c0b75564d62381
Parent: f6bfc7f
Committed by GitHub <noreply@github.com> on 5/29/2026, 7:20:25 AM