Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions pyrefly/lib/alt/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3112,6 +3112,13 @@ impl<'ctx, 'answer, Ans: LookupAnswer> AnswersSolver<'ctx, 'answer, Ans> {
"`NotImplemented` is not callable. Did you mean `NotImplementedError`?".to_owned(),
);
}
self.check_pydantic_model_validate_constraints(
ty,
&x.arguments.args,
&x.arguments.keywords,
x.arguments.range,
errors,
);
Comment on lines +3115 to +3121
match ty.callee_kind() {
Some(CalleeKind::Function(FunctionKind::AssertType)) => self
.call_assert_type(
Expand Down
13 changes: 13 additions & 0 deletions pyrefly/lib/alt/class/dataclass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,19 @@ impl<'ctx, 'answer, Ans: LookupAnswer> AnswersSolver<'ctx, 'answer, Ans> {
{
fields.insert(MODEL_CONSTRUCT, model_construct);
}
if metadata.is_pydantic_model()
&& !self
.get_class_fields(cls)
.is_some_and(|fields| fields.contains(&Name::new_static("model_validate")))
{
let root_model_type = self
.get_pydantic_root_model_type_via_mro(cls, metadata)
.map(|(ty, _)| ty);
fields.insert(
Name::new_static("model_validate"),
Comment on lines +224 to +233
self.get_pydantic_model_validate(cls, dataclass, root_model_type),
);
}
let dataclass_fields_type = self.stdlib.dict(
self.heap.mk_class_type(self.stdlib.str().clone()),
self.heap.mk_any_implicit(),
Expand Down
Loading
Loading