WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
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
5 changes: 5 additions & 0 deletions crates/pyrefly_types/src/callable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,7 @@ pub enum FunctionKind {
IsSubclass,
Dataclass,
DataclassField,
DataclassReplace,
/// `typing.dataclass_transform`. Note that this is `dataclass_transform` itself, *not* the
/// decorator created by a `dataclass_transform(...)` call. See
/// https://typing.python.org/en/latest/spec/dataclasses.html#specification.
Expand Down Expand Up @@ -810,6 +811,7 @@ impl FunctionKind {
("builtins", None, "classmethod") => Self::ClassMethod,
("dataclasses", None, "dataclass") => Self::Dataclass,
("dataclasses", None, "field") => Self::DataclassField,
("dataclasses", None, "replace") => Self::DataclassReplace,
("typing", None, "overload") => Self::Overload,
("typing", None, "override") => Self::Override,
("typing", None, "cast") => Self::Cast,
Expand Down Expand Up @@ -840,6 +842,7 @@ impl FunctionKind {
Self::ClassMethod => ModuleName::builtins(),
Self::Dataclass => ModuleName::dataclasses(),
Self::DataclassField => ModuleName::dataclasses(),
Self::DataclassReplace => ModuleName::dataclasses(),
Self::DataclassTransform => ModuleName::typing(),
Self::Final => ModuleName::typing(),
Self::Overload => ModuleName::typing(),
Expand All @@ -865,6 +868,7 @@ impl FunctionKind {
Self::ClassMethod => Cow::Owned(Name::new_static("classmethod")),
Self::Dataclass => Cow::Owned(Name::new_static("dataclass")),
Self::DataclassField => Cow::Owned(Name::new_static("field")),
Self::DataclassReplace => Cow::Owned(Name::new_static("replace")),
Self::DataclassTransform => Cow::Owned(Name::new_static("dataclass_transform")),
Self::Final => Cow::Owned(Name::new_static("final")),
Self::Overload => Cow::Owned(Name::new_static("overload")),
Expand All @@ -890,6 +894,7 @@ impl FunctionKind {
Self::ClassMethod => None,
Self::Dataclass => None,
Self::DataclassField => None,
Self::DataclassReplace => None,
Self::DataclassTransform => None,
Self::Final => None,
Self::Overload => None,
Expand Down
8 changes: 8 additions & 0 deletions pyrefly/lib/alt/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1243,6 +1243,14 @@ impl<'a, Ans: LookupAnswer> AnswersSolver<'a, Ans> {
errors,
)
}
Some(CalleeKind::Function(FunctionKind::DataclassReplace)) => {
self.call_dataclasses_replace(
&x.arguments.args,
&x.arguments.keywords,
x.arguments.range,
errors,
)
}
// Treat assert_type and reveal_type like pseudo-builtins for convenience. Note that we still
// log a name-not-found error, but we also assert/reveal the type as requested.
None if ty.is_error() && is_special_name(&x.func, "assert_type") => self
Expand Down
Loading