mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-09 18:02:19 +00:00
![]() ## Summary Switch name resolution in `infer_expression_type` from resolving the public type of a symbol, to resolving the reachable definitions of that symbol from the reference point, using the flow graph. This surfaced a bug in the flow graph implementation and a bug in symbol table building, both of which are also fixed here. The bug in flow graph implementation was that when we pushed and popped scopes, we didn't maintain a stack of "current flow nodes" in all stacked scopes, to be restored when we returned to that scope. Now we do. The bug in symbol table building that we didn't visit the parts of functions and class definitions in the correct scopes. E.g. decorators should be visited in the outer scope, arguments should be visited inside the type-params scope (if any) but not inside the function body scope, and only the body itself should actually be visited inside the body scope. Fixing this requires that we no longer use `walk_stmt` here, instead we have to visit each individual component. ## Test Plan Added test. |
||
---|---|---|
.. | ||
red_knot | ||
ruff | ||
ruff_benchmark | ||
ruff_cache | ||
ruff_dev | ||
ruff_diagnostics | ||
ruff_formatter | ||
ruff_index | ||
ruff_linter | ||
ruff_macros | ||
ruff_notebook | ||
ruff_python_ast | ||
ruff_python_ast_integration_tests | ||
ruff_python_codegen | ||
ruff_python_formatter | ||
ruff_python_index | ||
ruff_python_literal | ||
ruff_python_parser | ||
ruff_python_resolver | ||
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 |