ruff/crates/ruff_linter/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
..
checkers [ruff] Allow dataclass attribute value instantiation from nested frozen dataclass (RUF009) (#20352) 2025-09-12 16:46:49 -04:00
comments
cst Update Rust toolchain to 1.89 (#19807) 2025-08-07 18:21:50 +02:00
docstrings Update Rust toolchain to 1.89 (#19807) 2025-08-07 18:21:50 +02:00
fix Track t-strings and f-strings for token-based rules and suppression comments (#20357) 2025-09-12 13:00:12 -05:00
importer [isort] Handle multiple continuation lines after module docstring (I002) (#19818) 2025-08-15 17:17:50 -04:00
linter [pylint] Detect more exotic NaN literals in PLW0177 (#18630) 2025-06-19 11:05:06 +00:00
message Move GitHub rendering to ruff_db (#20320) 2025-09-11 13:11:15 -04:00
registry Remove Message::to_rule (#18447) 2025-06-05 12:48:29 -04:00
rules [ruff] Allow dataclass attribute value instantiation from nested frozen dataclass (RUF009) (#20352) 2025-09-12 16:46:49 -04:00
settings Stabilize adding future import via config option (#20277) 2025-09-10 09:00:27 -04:00
snapshots [syntax-errors] Detect yield from inside async function (#20051) 2025-09-03 10:13:05 -04:00
codes.rs Stabilize the remaining Airflow rules (#20250) 2025-09-10 09:00:27 -04:00
directives.rs Track t-strings and f-strings for token-based rules and suppression comments (#20357) 2025-09-12 13:00:12 -05:00
doc_lines.rs Update Rust toolchain to 1.89 (#19807) 2025-08-07 18:21:50 +02:00
fs.rs Move GitLab output rendering to ruff_db (#20117) 2025-08-28 08:56:33 -04:00
lib.rs Combine OldDiagnostic and Diagnostic (#19053) 2025-07-03 13:01:09 -04:00
line_width.rs Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
linter.rs Remove Diagnostic::expect_range and all consumers (#20322) 2025-09-10 17:19:20 -07:00
locator.rs Update Rust toolchain to 1.89 (#19807) 2025-08-07 18:21:50 +02:00
logging.rs Combine OldDiagnostic and Diagnostic (#19053) 2025-07-03 13:01:09 -04:00
noqa.rs Remove Diagnostic::expect_range and all consumers (#20322) 2025-09-10 17:19:20 -07:00
package.rs
packaging.rs
preview.rs [flake8-simplify] Detect unnecessary None default for additional key expression types (SIM910) (#20343) 2025-09-12 10:17:54 -04:00
pyproject_toml.rs Rename Diagnostic::syntax_error methods, separate Ord implementation (#19179) 2025-07-08 09:54:19 -04:00
registry.rs Apply fix availability and applicability when adding to DiagnosticGuard and remove NoqaCode::rule (#18834) 2025-06-24 10:08:36 -04:00
renamer.rs Add a ScopeKind for the __class__ cell (#20048) 2025-08-26 09:49:08 -04:00
rule_redirects.rs [flake8-bandit] Move unsafe-markup-use from RUF035 to S704 (#15957) 2025-03-13 15:37:37 +01:00
rule_selector.rs Ignore deprecated rules unless selected by exact code (#20167) 2025-09-10 09:00:27 -04:00
source_kind.rs Update MSRV to 1.85 and toolchain to 1.87 (#18126) 2025-05-16 09:19:55 +02:00
test.rs Remove Diagnostic::expect_range and all consumers (#20322) 2025-09-10 17:19:20 -07:00
text_helpers.rs
upstream_categories.rs
violation.rs Rename Diagnostic::syntax_error methods, separate Ord implementation (#19179) 2025-07-08 09:54:19 -04:00