mirror of
https://github.com/microsoft/pyright.git
synced 2024-09-11 07:55:56 +03:00
Updated logic for dataclass_transform
to handle recent clarification in PEP 681 for cases where one or more overloads are decorated with dataclass_transform
.
This commit is contained in:
parent
139139a9a2
commit
dc153cb35d
@ -738,7 +738,13 @@ export function getDataclassDecoratorBehaviors(type: Type): DataClassBehaviors |
|
||||
if (isFunction(type)) {
|
||||
functionType = type;
|
||||
} else if (isOverloadedFunction(type)) {
|
||||
functionType = type.overloads[0];
|
||||
// Find the first overload or implementation that contains a
|
||||
// dataclass_transform decorator. If more than one have such a decorator,
|
||||
// only the first one will be honored, as per PEP 681.
|
||||
functionType =
|
||||
type.overloads.find((overload) => {
|
||||
overload.details.decoratorDataClassBehaviors !== undefined;
|
||||
}) ?? type.overloads[0];
|
||||
}
|
||||
|
||||
if (!functionType) {
|
||||
|
Loading…
Reference in New Issue
Block a user