Skip to content

Commit 7b90e9e

Browse files
authored
Made PEP 728 (TypedDict with extra items) no longer experimental since it has been accepted by the SC. (#10804)
1 parent de2d23d commit 7b90e9e

File tree

4 files changed

+17
-63
lines changed

4 files changed

+17
-63
lines changed

docs/features.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Pyright supports [configuration files](configuration.md) that provide granular c
3535
* [PEP 698](https://www.python.org/dev/peps/pep-0698/) override decorator for static typing
3636
* [PEP 702](https://www.python.org/dev/peps/pep-0702/) marking deprecations
3737
* [PEP 705](https://www.python.org/dev/peps/pep-0705/) TypedDict: read-only items
38-
* [PEP 728](https://www.python.org/dev/peps/pep-0728/) (experimental) TypedDict with typed extra items
38+
* [PEP 728](https://www.python.org/dev/peps/pep-0728/) TypedDict with typed extra items
3939
* [PEP 742](https://www.python.org/dev/peps/pep-0742/) narrowing types with TypeIs
4040
* [PEP 746](https://www.python.org/dev/peps/pep-0746/) (experimental) type checking annotated metadata
4141
* [PEP 747](https://www.python.org/dev/peps/pep-0747/) (experimental) annotating type forms

packages/pyright-internal/src/analyzer/typeEvaluator.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17707,10 +17707,7 @@ export function createTypeEvaluator(
1770717707
);
1770817708
} else if (arg.d.name.d.value === 'total' && !constArgValue) {
1770917709
classType.shared.flags |= ClassTypeFlags.CanOmitDictValues;
17710-
} else if (
17711-
arg.d.name.d.value === 'closed' &&
17712-
AnalyzerNodeInfo.getFileInfo(node).diagnosticRuleSet.enableExperimentalFeatures
17713-
) {
17710+
} else if (arg.d.name.d.value === 'closed') {
1771417711
if (constArgValue) {
1771517712
classType.shared.flags |=
1771617713
ClassTypeFlags.TypedDictMarkedClosed | ClassTypeFlags.TypedDictEffectivelyClosed;
@@ -17734,10 +17731,7 @@ export function createTypeEvaluator(
1773417731

1773517732
sawClosedOrExtraItems = true;
1773617733
}
17737-
} else if (
17738-
arg.d.name.d.value === 'extra_items' &&
17739-
AnalyzerNodeInfo.getFileInfo(node).diagnosticRuleSet.enableExperimentalFeatures
17740-
) {
17734+
} else if (arg.d.name.d.value === 'extra_items') {
1774117735
// Record a reference to the expression but don't evaluate it yet.
1774217736
// It may refer to the class itself.
1774317737
classType.shared.typedDictExtraItemsExpr = arg.d.valueExpr;

packages/pyright-internal/src/analyzer/typedDicts.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -206,10 +206,7 @@ export function createTypedDictType(
206206
);
207207
} else if (arg.name.d.value === 'total' && arg.valueExpression.d.constType === KeywordType.False) {
208208
classType.shared.flags |= ClassTypeFlags.CanOmitDictValues;
209-
} else if (
210-
arg.name.d.value === 'closed' &&
211-
AnalyzerNodeInfo.getFileInfo(errorNode).diagnosticRuleSet.enableExperimentalFeatures
212-
) {
209+
} else if (arg.name.d.value === 'closed') {
213210
if (arg.valueExpression.d.constType === KeywordType.True) {
214211
classType.shared.flags |=
215212
ClassTypeFlags.TypedDictMarkedClosed | ClassTypeFlags.TypedDictEffectivelyClosed;
@@ -225,10 +222,7 @@ export function createTypedDictType(
225222

226223
sawClosedOrExtraItems = true;
227224
}
228-
} else if (
229-
arg.name?.d.value === 'extra_items' &&
230-
AnalyzerNodeInfo.getFileInfo(errorNode).diagnosticRuleSet.enableExperimentalFeatures
231-
) {
225+
} else if (arg.name?.d.value === 'extra_items') {
232226
classType.shared.typedDictExtraItemsExpr = arg.valueExpression;
233227
classType.shared.flags |= ClassTypeFlags.TypedDictEffectivelyClosed;
234228

packages/pyright-internal/src/tests/typeEvaluator5.test.ts

Lines changed: 12 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -339,96 +339,62 @@ test('TypeAliasType2', () => {
339339
});
340340

341341
test('TypedDictReadOnly1', () => {
342-
const configOptions = new ConfigOptions(Uri.empty());
343-
344-
const analysisResults = TestUtils.typeAnalyzeSampleFiles(['typedDictReadOnly1.py'], configOptions);
342+
const analysisResults = TestUtils.typeAnalyzeSampleFiles(['typedDictReadOnly1.py']);
345343
TestUtils.validateResults(analysisResults, 4);
346344
});
347345

348346
test('TypedDictReadOnly2', () => {
349-
const configOptions = new ConfigOptions(Uri.empty());
350-
351-
const analysisResults = TestUtils.typeAnalyzeSampleFiles(['typedDictReadOnly2.py'], configOptions);
347+
const analysisResults = TestUtils.typeAnalyzeSampleFiles(['typedDictReadOnly2.py']);
352348
TestUtils.validateResults(analysisResults, 17);
353349
});
354350

355351
test('TypedDictClosed1', () => {
356-
const configOptions = new ConfigOptions(Uri.empty());
357-
configOptions.diagnosticRuleSet.enableExperimentalFeatures = true;
358-
359-
const analysisResults = TestUtils.typeAnalyzeSampleFiles(['typedDictClosed1.py'], configOptions);
352+
const analysisResults = TestUtils.typeAnalyzeSampleFiles(['typedDictClosed1.py']);
360353
TestUtils.validateResults(analysisResults, 7);
361354
});
362355

363356
test('TypedDictClosed2', () => {
364-
const configOptions = new ConfigOptions(Uri.empty());
365-
configOptions.diagnosticRuleSet.enableExperimentalFeatures = true;
366-
367-
const analysisResults = TestUtils.typeAnalyzeSampleFiles(['typedDictClosed2.py'], configOptions);
357+
const analysisResults = TestUtils.typeAnalyzeSampleFiles(['typedDictClosed2.py']);
368358
TestUtils.validateResults(analysisResults, 4);
369359
});
370360

371361
test('TypedDictClosed3', () => {
372-
const configOptions = new ConfigOptions(Uri.empty());
373-
configOptions.diagnosticRuleSet.enableExperimentalFeatures = true;
374-
375-
const analysisResults = TestUtils.typeAnalyzeSampleFiles(['typedDictClosed3.py'], configOptions);
362+
const analysisResults = TestUtils.typeAnalyzeSampleFiles(['typedDictClosed3.py']);
376363
TestUtils.validateResults(analysisResults, 10);
377364
});
378365

379366
test('TypedDictClosed4', () => {
380-
const configOptions = new ConfigOptions(Uri.empty());
381-
configOptions.diagnosticRuleSet.enableExperimentalFeatures = true;
382-
383-
const analysisResults = TestUtils.typeAnalyzeSampleFiles(['typedDictClosed4.py'], configOptions);
367+
const analysisResults = TestUtils.typeAnalyzeSampleFiles(['typedDictClosed4.py']);
384368
TestUtils.validateResults(analysisResults, 5);
385369
});
386370

387371
test('TypedDictClosed5', () => {
388-
const configOptions = new ConfigOptions(Uri.empty());
389-
configOptions.diagnosticRuleSet.enableExperimentalFeatures = true;
390-
391-
const analysisResults = TestUtils.typeAnalyzeSampleFiles(['typedDictClosed5.py'], configOptions);
372+
const analysisResults = TestUtils.typeAnalyzeSampleFiles(['typedDictClosed5.py']);
392373
TestUtils.validateResults(analysisResults, 1);
393374
});
394375

395376
test('TypedDictClosed6', () => {
396-
const configOptions = new ConfigOptions(Uri.empty());
397-
configOptions.diagnosticRuleSet.enableExperimentalFeatures = true;
398-
399-
const analysisResults = TestUtils.typeAnalyzeSampleFiles(['typedDictClosed6.py'], configOptions);
377+
const analysisResults = TestUtils.typeAnalyzeSampleFiles(['typedDictClosed6.py']);
400378
TestUtils.validateResults(analysisResults, 8);
401379
});
402380

403381
test('TypedDictClosed7', () => {
404-
const configOptions = new ConfigOptions(Uri.empty());
405-
configOptions.diagnosticRuleSet.enableExperimentalFeatures = true;
406-
407-
const analysisResults = TestUtils.typeAnalyzeSampleFiles(['typedDictClosed7.py'], configOptions);
382+
const analysisResults = TestUtils.typeAnalyzeSampleFiles(['typedDictClosed7.py']);
408383
TestUtils.validateResults(analysisResults, 6);
409384
});
410385

411386
test('TypedDictClosed8', () => {
412-
const configOptions = new ConfigOptions(Uri.empty());
413-
configOptions.diagnosticRuleSet.enableExperimentalFeatures = true;
414-
415-
const analysisResults = TestUtils.typeAnalyzeSampleFiles(['typedDictClosed8.py'], configOptions);
387+
const analysisResults = TestUtils.typeAnalyzeSampleFiles(['typedDictClosed8.py']);
416388
TestUtils.validateResults(analysisResults, 0);
417389
});
418390

419391
test('TypedDictClosed9', () => {
420-
const configOptions = new ConfigOptions(Uri.empty());
421-
configOptions.diagnosticRuleSet.enableExperimentalFeatures = true;
422-
423-
const analysisResults = TestUtils.typeAnalyzeSampleFiles(['typedDictClosed9.py'], configOptions);
392+
const analysisResults = TestUtils.typeAnalyzeSampleFiles(['typedDictClosed9.py']);
424393
TestUtils.validateResults(analysisResults, 1);
425394
});
426395

427396
test('TypedDictClosed10', () => {
428-
const configOptions = new ConfigOptions(Uri.empty());
429-
configOptions.diagnosticRuleSet.enableExperimentalFeatures = true;
430-
431-
const analysisResults = TestUtils.typeAnalyzeSampleFiles(['typedDictClosed10.py'], configOptions);
397+
const analysisResults = TestUtils.typeAnalyzeSampleFiles(['typedDictClosed10.py']);
432398
TestUtils.validateResults(analysisResults, 0);
433399
});
434400

0 commit comments

Comments
 (0)