mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-17 05:47:37 +00:00
![]() ## 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. |
||
---|---|---|
.. | ||
ruff | ||
ruff_annotate_snippets | ||
ruff_benchmark | ||
ruff_cache | ||
ruff_db | ||
ruff_dev | ||
ruff_diagnostics | ||
ruff_formatter | ||
ruff_graph | ||
ruff_index | ||
ruff_linter | ||
ruff_macros | ||
ruff_memory_usage | ||
ruff_notebook | ||
ruff_options_metadata | ||
ruff_python_ast | ||
ruff_python_ast_integration_tests | ||
ruff_python_codegen | ||
ruff_python_formatter | ||
ruff_python_importer | ||
ruff_python_index | ||
ruff_python_literal | ||
ruff_python_parser | ||
ruff_python_semantic | ||
ruff_python_stdlib | ||
ruff_python_trivia | ||
ruff_python_trivia_integration_tests | ||
ruff_server | ||
ruff_source_file | ||
ruff_text_size | ||
ruff_wasm | ||
ruff_workspace | ||
ty | ||
ty_combine | ||
ty_completion_eval | ||
ty_ide | ||
ty_project | ||
ty_python_semantic | ||
ty_server | ||
ty_static | ||
ty_test | ||
ty_vendored | ||
ty_wasm |