From 6dc3b399027eec51feeb65a0ec20de954d82c42f Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Sat, 15 Jun 2024 18:28:09 +0200 Subject: [PATCH] Fixed a bug in the "type printer" (the component responsible for translating a type into its textual form) for type aliases defined using PEP 695 syntax. --- .../pyright-internal/src/analyzer/typePrinter.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/pyright-internal/src/analyzer/typePrinter.ts b/packages/pyright-internal/src/analyzer/typePrinter.ts index fdd07ba5d..d5ddbba37 100644 --- a/packages/pyright-internal/src/analyzer/typePrinter.ts +++ b/packages/pyright-internal/src/analyzer/typePrinter.ts @@ -449,8 +449,19 @@ function printTypeInternal( typeToWrap = `Literal[${printLiteralValue(type)}]`; } } else { + if (type.specialForm) { + return printTypeInternal( + type.specialForm, + printTypeFlags, + returnTypeCallback, + uniqueNameMap, + recursionTypes, + recursionCount + ); + } + typeToWrap = printObjectTypeForClassInternal( - type.specialForm ?? type, + type, printTypeFlags, returnTypeCallback, uniqueNameMap,