ruff/crates/ty_python_semantic
David Peter 2dbca6370b
[ty] Avoid ever-growing default types (#20991)
## Summary

We currently panic in the seemingly rare case where the type of a
default value of a parameter depends on the callable itself:
```py
class C:
    def f(self: C):
        self.x = lambda a=self.x: a
```

Types of default values are only used for display reasons, and it's
unclear if we even want to track them (or if we should rather track the
actual value). So it didn't seem to me that we should spend a lot of
effort (and runtime) trying to achieve a theoretically correct type here
(which would be infinite).

Instead, we simply replace *nested* default types with `Unknown`, i.e.
only if the type of the default value is a callable itself.

closes https://github.com/astral-sh/ty/issues/1402

## Test Plan

Regression tests
2025-10-21 19:13:36 +02:00
..
resources [ty] Avoid ever-growing default types (#20991) 2025-10-21 19:13:36 +02:00
src [ty] Avoid ever-growing default types (#20991) 2025-10-21 19:13:36 +02:00
tests [ty] Limit shown import paths to at most 5 unless ty runs with -v (#20912) 2025-10-16 13:18:09 +02:00
build.rs
Cargo.toml [ruff] Update schemars to v1 (#20942) 2025-10-20 08:59:52 +02:00
mdtest.py [ty] Faster iteration on mdtests (#20465) 2025-09-18 10:48:52 +00:00
mdtest.py.lock