зеркало из https://github.com/microsoft/pyright.git
Changed synthesized comparison methods (`__lt__`, etc.) for dataclasses when `order=True` to use `Self` rather than an instance of the class. This is not only more consistent with other synthesized methods, but it also preserves covariance of type variables if the dataclass is frozen. (#8734)
This commit is contained in:
Родитель
465b04c80b
Коммит
1a17c0aa6b
|
@ -624,9 +624,8 @@ export function synthesizeDataClassMethods(
|
|||
}
|
||||
|
||||
if (ClassType.isDataClassGenerateOrder(classType)) {
|
||||
const objType = ClassType.cloneAsInstance(classType);
|
||||
['__lt__', '__le__', '__gt__', '__ge__'].forEach((operator) => {
|
||||
synthesizeComparisonMethod(operator, objType);
|
||||
synthesizeComparisonMethod(operator, selfType);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче