Skip to content

Conversation

@IDrokin117
Copy link
Contributor

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

@github-actions
Copy link
Contributor

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@ntBre ntBre added the rule Implementing or modifying a lint rule label Sep 12, 2025
Copy link
Contributor

@ntBre ntBre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! This makes sense to me

@ntBre ntBre merged commit c7f6b85 into astral-sh:main Sep 12, 2025
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rule Implementing or modifying a lint rule

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RUF009 - Frozen Dataclass with nested class should be valid

2 participants