Skip to content

Commit

Permalink
Fixed a bug that results in a false positive error when using `__extr…
Browse files Browse the repository at this point in the history
…a_items__` (PEP 728) with a `TypedDict` imported from `typing_extensions`. This addresses #7784.
  • Loading branch information
erictraut committed Apr 27, 2024
1 parent 2743ba5 commit 47c53f9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/pyright-internal/src/analyzer/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6751,7 +6751,11 @@ export class Checker extends ParseTreeWalker {
}
}

if (isBaseClassVar !== isClassVar) {
// Allow TypedDict members to have the same name as class variables in the
// base class because TypedDict members are not really instance members.
const ignoreTypedDictOverride = ClassType.isTypedDictClass(childClassType) && !isClassVar;

if (isBaseClassVar !== isClassVar && !ignoreTypedDictOverride) {
const unformattedMessage = overrideSymbol.isClassVar()
? LocMessage.classVarOverridesInstanceVar()
: LocMessage.instanceVarOverridesClassVar();
Expand Down

0 comments on commit 47c53f9

Please sign in to comment.