-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[ty] Dataclass transform: neither frozen nor non-frozen #23366
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1061,24 +1061,20 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { | |
| } | ||
|
|
||
| if let Some((base_class_literal, _)) = base_class.static_class_literal(self.db()) | ||
| && let (Some(base_params), Some(class_params)) = ( | ||
| base_class_literal.dataclass_params(self.db()), | ||
| class.dataclass_params(self.db()), | ||
| && let (Some(base_is_frozen), Some(class_is_frozen)) = ( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Out of curiosity, is it even possible for
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Hmm.. probably not? Even if the class itself has a metaclass that is not a |
||
| base_class_literal.is_frozen_dataclass(self.db()), | ||
| class.is_frozen_dataclass(self.db()), | ||
| ) | ||
| && base_is_frozen != class_is_frozen | ||
| { | ||
| let base_params = base_params.flags(self.db()); | ||
| let class_is_frozen = class_params.flags(self.db()).is_frozen(); | ||
|
|
||
| if base_params.is_frozen() != class_is_frozen { | ||
| report_bad_frozen_dataclass_inheritance( | ||
| &self.context, | ||
| class, | ||
| class_node, | ||
| base_class_literal, | ||
| &class_node.bases()[i], | ||
| base_params, | ||
| ); | ||
| } | ||
| report_bad_frozen_dataclass_inheritance( | ||
| &self.context, | ||
| class, | ||
| class_node, | ||
| base_class_literal, | ||
| &class_node.bases()[i], | ||
| base_is_frozen, | ||
| ); | ||
| } | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Look, we found a mistake in our tests. This should be frozen so that
TemperatureSensorbelow can be frozen. I checked and this is actually the case in home assistant. I just forgot to include it at the time.