fix(python): a member value through an untyped receiver is a method only its owner names (#2218)

A lone project method now stands for an untyped receiver's member value only
when the receiver is named after the method's class: netbox's
`device=self.parent.device` model-field reads no longer reach a GraphQL
filter's `device` method.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Colby Mchenry
2026-09-30 23:18:21 +00:00
committed by GitHub
co-authored by Claude Opus 5.5
parent fa43e259b2
commit e62032e95a
3 changed files with 70 additions and 2 deletions
+8 -2
View File
@@ -325,8 +325,14 @@ function matchMemberFunctionRef(ref: UnresolvedRef, context: ResolutionContext):
}
}
// Unknown receivers retain the old unique-or-drop discipline, across ALL
// files. Tests and abstract-looking bodies are candidates too.
return result(context.getNodesByName(member), 0.8);
// files. Tests and abstract-looking bodies are candidates too. A lone method
// stands only when the receiver is named after its owner: netbox's
// `device=self.parent.device` is a model field, not the project's one
// `device` method (a GraphQL filter's). A veto, never a filter — filtering
// first would promote some other lone match into a new guess.
const unique = result(context.getNodesByName(member), 0.8);
const target = unique ? context.getNodeById?.(unique.targetNodeId) : null;
return target && target.kind === 'method' && !sharesReceiverWord(receiverLink(receiver), target) ? null : unique;
}
function pythonRefClass(name: string, ref: UnresolvedRef, context: ResolutionContext): Node | null {