ruff/crates
David Peter 4b8e278a88
[ty] Treat Callables as bound-method descriptors in special cases (#20802)
## Summary

Treat `Callable`s as bound-method descriptors if `Callable` is the
return type of a decorator that is applied to a function definition. See
the [rendered version of the new test
file](https://github.com/astral-sh/ruff/blob/david/callables-as-descriptors/crates/ty_python_semantic/resources/mdtest/call/callables_as_descriptors.md)
for the full description of this new heuristic.

I could imagine that we want to treat `Callable`s as bound-method
descriptors in other cases as well, but this seems like a step in the
right direction. I am planning to add other "use cases" from
https://github.com/astral-sh/ty/issues/491 to this test suite.

partially addresses https://github.com/astral-sh/ty/issues/491
closes https://github.com/astral-sh/ty/issues/1333

## Ecosystem impact

All positive

* 2961 removed `unsupported-operator` diagnostics on `sympy`, which was
one of the main motivations for implementing this change
* 37 removed `missing-argument` diagnostics, and no added call-error
diagnostics, which is an indicator that this heuristic shouldn't cause
many false positives
* A few removed `possibly-missing-attribute` diagnostics when accessing
attributes like `__name__` on decorated functions. The two added
`unused-ignore-comment` diagnostics are also cases of this.
* One new `invalid-assignment` diagnostic on `dd-trace-py`, which looks
suspicious, but only because our `invalid-assignment` diagnostics are
not great. This is actually a "Implicit shadowing of function"
diagnostic that hides behind the `invalid-assignment` diagnostic,
because a module-global function is being patched through a
`module.func` attribute assignment.

## Test Plan

New Markdown tests.
2025-10-13 21:17:47 +02:00
..
ruff Bump 0.14.0 (#20751) 2025-10-07 11:05:47 -07:00
ruff_annotate_snippets Display diffs for ruff format --check and add support for different output formats (#20443) 2025-09-30 12:00:51 -04:00
ruff_benchmark Shard ty walltime benchmarks (#20791) 2025-10-10 07:55:50 +02:00
ruff_cache Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
ruff_db Render unsupported syntax errors in formatter tests (#20777) 2025-10-13 10:00:37 -04:00
ruff_dev [ty] Remove duplicate global lint registry (#20053) 2025-08-22 19:43:12 -04:00
ruff_diagnostics Fix rust feature activation (#20012) 2025-08-21 09:26:06 +02:00
ruff_formatter Display diffs for ruff format --check and add support for different output formats (#20443) 2025-09-30 12:00:51 -04:00
ruff_graph [ty] Remove KnownModule::is_enum (#19681) 2025-08-01 10:31:12 +02:00
ruff_index Update Rust toolchain to 1.88 and MSRV to 1.86 (#19011) 2025-06-28 20:24:00 +02:00
ruff_linter Render unsupported syntax errors in formatter tests (#20777) 2025-10-13 10:00:37 -04:00
ruff_macros Replace two more uses of unsafe with const Option::unwrap (#20584) 2025-09-25 15:35:13 -04:00
ruff_memory_usage [ty] Clean up inherited generic contexts (#20647) 2025-10-03 13:55:43 -04:00
ruff_notebook Display diffs for ruff format --check and add support for different output formats (#20443) 2025-09-30 12:00:51 -04:00
ruff_options_metadata Update Rust toolchain to 1.89 (#19807) 2025-08-07 18:21:50 +02:00
ruff_python_ast [ty] Use 3.14 as the default version (#20759) 2025-10-08 11:38:47 +02:00
ruff_python_ast_integration_tests Disallow implicit concatenation of t-strings and other string types (#19485) 2025-07-27 12:41:03 +00:00
ruff_python_codegen Generator preferred quote style (#20434) 2025-09-18 12:57:21 +02:00
ruff_python_formatter Fix syntax error false positives on parenthesized context managers (#20846) 2025-10-13 14:13:27 -04:00
ruff_python_importer [ruff] Add API for splicing into an existing import statement 2025-09-17 13:59:28 -04:00
ruff_python_index Track t-strings and f-strings for token-based rules and suppression comments (#20357) 2025-09-12 13:00:12 -05:00
ruff_python_literal Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
ruff_python_parser Fix syntax error false positives on parenthesized context managers (#20846) 2025-10-13 14:13:27 -04:00
ruff_python_semantic [ruff] Extend FA102 with listed PEP 585-compatible APIs (#20659) 2025-10-03 09:45:32 -04:00
ruff_python_stdlib [ruff] Extend FA102 with listed PEP 585-compatible APIs (#20659) 2025-10-03 09:45:32 -04:00
ruff_python_trivia Handle t-string prefixes in SimpleTokenizer (#20578) 2025-09-25 14:33:37 -05:00
ruff_python_trivia_integration_tests Handle t-string prefixes in SimpleTokenizer (#20578) 2025-09-25 14:33:37 -05:00
ruff_server Use Annotation::tags instead of hardcoded rule matching in ruff server (#20565) 2025-09-26 09:06:26 +02:00
ruff_source_file Move diff rendering to ruff_db (#20006) 2025-08-21 09:47:00 -04:00
ruff_text_size [ruff] Add TextRange::to_std_range 2025-09-17 13:59:28 -04:00
ruff_wasm Bump 0.14.0 (#20751) 2025-10-07 11:05:47 -07:00
ruff_workspace Update default and latest Python versions for 3.14 (#20725) 2025-10-07 12:23:11 -04:00
ty [ty] Remove 'pre-release software' warning (#20817) 2025-10-13 19:50:19 +02:00
ty_combine [ty] Disallow std::env and io methods in most ty crates (#20046) 2025-08-22 11:13:47 -07:00
ty_completion_eval [ty] Add an evaluation for completions 2025-10-08 08:44:21 -04:00
ty_ide [ty] defer inference of legacy TypeVar bound/constraints/defaults (#20598) 2025-10-09 21:08:37 +00:00
ty_project [ty] Use 3.14 as the default version (#20759) 2025-10-08 11:38:47 +02:00
ty_python_semantic [ty] Treat Callables as bound-method descriptors in special cases (#20802) 2025-10-13 21:17:47 +02:00
ty_server [ty] Improve diagnostics for bad @overload definitions (#20745) 2025-10-07 21:52:57 +00:00
ty_static [ty] improve base conda distinction from child conda (#20675) 2025-10-03 13:56:06 +00:00
ty_test [ty] Filter out revealed-type and undefined-reveal diagnostics from mdtest snapshots (#20820) 2025-10-12 18:39:32 +00:00
ty_vendored [ty] Sync vendored typeshed stubs (#20658) 2025-10-01 10:11:48 +02:00
ty_wasm [ruff,ty] Enable tracing's log feature 2025-10-03 08:18:03 -04:00