mirror of
https://github.com/astral-sh/ruff
synced 2026-01-21 21:40:51 -05:00
## Summary Other type checkers allow you to access all `FunctionType` attributes on any object with a `Callable` type. ty does not, because this is demonstrably unsound, but this is often a source of confusion for users. And there were lots of diagnostics in the ecosystem report for https://github.com/astral-sh/ruff/pull/22145 that were complaining that "Object of type `(...) -> Unknown` has no attribute `__name__`", for example. The discrepancy between what ty does here and what other type checkers do is discussed a bit in https://github.com/astral-sh/ty/issues/1495. You can see that there have been lots of issues closed as duplicates of that issue; we should probably also add an FAQ entry for it. Anyway, this PR adds a subdiagnostic to help users out when they hit this diagnostic. Unfortunately something I did meant that rustfmt increased the indentation of the whole of this huge closure, so this PR is best reviewed with the "No whitespace" option selected for viewing the diff. ## Test Plan Snapshot added
Markdown files within the mdtest/ subdirectory are tests of type inference and type checking;
executed by the tests/mdtest.rs integration test.
See crates/ty_test/README.md for documentation of this test format.