mirror of
https://github.com/microsoft/pyright.git
synced 2024-09-11 07:55:56 +03:00
Changed support for dataclass "converter" field parameter to be off by default. The "enableExperimentalFeatures" must now be enabled to use this feature. If and when PEP 712 is approved, we can move out of experimental.
This commit is contained in:
parent
017f7c2767
commit
7426e71d2c
@ -302,7 +302,10 @@ export function synthesizeDataClassMethods(
|
||||
(arg) => arg.name?.value === 'converter'
|
||||
);
|
||||
if (converterArg && converterArg.valueExpression) {
|
||||
converter = converterArg;
|
||||
// Converter support is dependent on PEP 712, which has not yet been approved.
|
||||
if (AnalyzerNodeInfo.getFileInfo(node).diagnosticRuleSet.enableExperimentalFeatures) {
|
||||
converter = converterArg;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -385,13 +385,17 @@ test('DataClassDescriptors2', () => {
|
||||
});
|
||||
|
||||
test('DataClassConverter1', () => {
|
||||
const analysisResults = TestUtils.typeAnalyzeSampleFiles(['dataclassConverter1.py']);
|
||||
const configOptions = new ConfigOptions(Uri.empty());
|
||||
configOptions.diagnosticRuleSet.enableExperimentalFeatures = true;
|
||||
const analysisResults = TestUtils.typeAnalyzeSampleFiles(['dataclassConverter1.py'], configOptions);
|
||||
|
||||
TestUtils.validateResults(analysisResults, 17);
|
||||
});
|
||||
|
||||
test('DataClassConverter2', () => {
|
||||
const analysisResults = TestUtils.typeAnalyzeSampleFiles(['dataclassConverter2.py']);
|
||||
const configOptions = new ConfigOptions(Uri.empty());
|
||||
configOptions.diagnosticRuleSet.enableExperimentalFeatures = true;
|
||||
const analysisResults = TestUtils.typeAnalyzeSampleFiles(['dataclassConverter2.py'], configOptions);
|
||||
|
||||
TestUtils.validateResults(analysisResults, 4);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user