Skip to content

Commit 58094a5

Browse files
authored
Changed behavior of pyright to match the latest typing spec when it encounters an attribute with a type annotation within an Enum class body in a stub. These are now treated as non-member attributes rather than members. Typeshed stubs have been updated to conform to the new standard. This addresses #8061. (#8063)
1 parent 46eba6a commit 58094a5

File tree

1 file changed

+0
-14
lines changed
  • packages/pyright-internal/src/analyzer

1 file changed

+0
-14
lines changed

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

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -310,13 +310,6 @@ export function transformTypeForEnumMember(
310310

311311
const primaryDecl = decls[0];
312312

313-
// In ".py" files, the transform applies only to members that are
314-
// assigned within the class. In stub files, it applies to most variables
315-
// even if they are not assigned. This unfortunate convention means
316-
// there is no way in a stub to specify both enum members and instance
317-
// variables used within each enum instance. Unless/until there is
318-
// a change to this convention and all type checkers and stubs adopt
319-
// it, we're stuck with this limitation.
320313
let isMemberOfEnumeration = false;
321314
let isUnpackedTuple = false;
322315
let valueTypeExprNode: ExpressionNode | undefined;
@@ -342,13 +335,6 @@ export function transformTypeForEnumMember(
342335
isMemberOfEnumeration = true;
343336
isUnpackedTuple = true;
344337
valueTypeExprNode = nameNode.parent.parent.rightExpression;
345-
} else if (
346-
getFileInfo(nameNode).isStubFile &&
347-
nameNode.parent?.nodeType === ParseNodeType.TypeAnnotation &&
348-
nameNode.parent.valueExpression === nameNode
349-
) {
350-
isMemberOfEnumeration = true;
351-
declaredTypeNode = nameNode.parent.typeAnnotation;
352338
}
353339

354340
// The spec specifically excludes names that start and end with a single underscore.

0 commit comments

Comments
 (0)