ruff/crates/ruff_python_semantic/src
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
..
analyze [ty] Make Module a Salsa ingredient 2025-07-23 09:46:40 -04:00
cfg Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
model [ty] AST garbage collection (#18482) 2025-06-13 08:40:11 -04:00
binding.rs Add a ScopeKind for the __class__ cell (#20048) 2025-08-26 09:49:08 -04:00
branches.rs Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
context.rs Remove separate ReferenceContext enum (#4631) 2023-05-24 15:12:38 +00:00
definition.rs [ty] Make Module a Salsa ingredient 2025-07-23 09:46:40 -04:00
globals.rs [ty] AST garbage collection (#18482) 2025-06-13 08:40:11 -04:00
imports.rs Update Rust toolchain to 1.89 (#19807) 2025-08-07 18:21:50 +02:00
lib.rs Control flow graph: setup (#17064) 2025-04-01 05:53:42 -05:00
model.rs [ruff] Allow dataclass attribute value instantiation from nested frozen dataclass (RUF009) (#20352) 2025-09-12 16:46:49 -04:00
nodes.rs Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
reference.rs Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
scope.rs Add a ScopeKind for the __class__ cell (#20048) 2025-08-26 09:49:08 -04:00
star_import.rs Make ImportFrom level just a u32 (#11170) 2024-04-26 20:38:35 -06:00