ruff/crates/ruff_python_semantic
Igor Drokin c7f6b85fb3
[ruff] Allow dataclass attribute value instantiation from nested frozen dataclass (RUF009) (#20352)
## Summary
Resolves #20266

Definition of the frozen dataclass attribute can be instantiation of a
nested frozen dataclass as well as a non-nested one.

### Problem explanation
The `function_call_in_dataclass_default` function is invoked during the
"defined scope" stage, after all scopes have been processed. At this
point, the semantic references the top-level scope. When
`SemanticModel::lookup_attribute` executes, it searches for bindings in
the top-level module scope rather than the class scope, resulting in an
error.

To solve this issue, the lookup should be evaluated through the class
scope.

## Test Plan
- Added test case from issue

Co-authored-by: Igor Drokin <drokinii1017@gmail.com>
2025-09-12 16:46:49 -04:00
..
resources/test/fixtures/cfg Control flow: return and raise (#17121) 2025-04-03 08:30:29 -05:00
src [ruff] Allow dataclass attribute value instantiation from nested frozen dataclass (RUF009) (#20352) 2025-09-12 16:46:49 -04:00
Cargo.toml Control flow graph: setup (#17064) 2025-04-01 05:53:42 -05:00