Skip to content

Commit

Permalink
Improved handling of __getitem__, __setitem__ and __delitem__ m…
Browse files Browse the repository at this point in the history
…agic method modeling to handle descriptor objects. This addresses #9653. (#9654)
  • Loading branch information
erictraut authored Jan 3, 2025
1 parent a03e8e4 commit a254b79
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/pyright-internal/src/analyzer/typeEvaluator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7494,7 +7494,9 @@ export function createTypeEvaluator(
) {
const itemMethodType = getBoundMagicMethod(
concreteSubtype,
getIndexAccessMagicMethodName(usage)
getIndexAccessMagicMethodName(usage),
/* selfType */ undefined,
node.d.leftExpr
);

if ((flags & EvalFlags.TypeExpression) !== 0) {
Expand Down Expand Up @@ -7844,7 +7846,7 @@ export function createTypeEvaluator(
}

const magicMethodName = getIndexAccessMagicMethodName(usage);
const itemMethodType = getBoundMagicMethod(baseType, magicMethodName, selfType);
const itemMethodType = getBoundMagicMethod(baseType, magicMethodName, selfType, node.d.leftExpr);

if (!itemMethodType) {
addDiagnostic(
Expand Down

0 comments on commit a254b79

Please sign in to comment.