@zzzen/pyright-internal 1.2.0-dev.20240505 → 1.2.0-dev.20240512

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1202,14 +1202,14 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
1202
1202
  }
1203
1203
  const exprTypeResult = this._evaluator.getTypeOfExpression(expression);
1204
1204
  let isExprFunction = true;
1205
- let isCoroutine = false;
1205
+ let isCoroutine = true;
1206
1206
  (0, typeUtils_1.doForEachSubtype)(exprTypeResult.type, (subtype) => {
1207
1207
  subtype = this._evaluator.makeTopLevelTypeVarsConcrete(subtype);
1208
1208
  if (!(0, types_1.isFunction)(subtype) && !(0, types_1.isOverloadedFunction)(subtype)) {
1209
1209
  isExprFunction = false;
1210
1210
  }
1211
- if ((0, types_1.isClassInstance)(subtype) && types_1.ClassType.isBuiltIn(subtype, 'Coroutine')) {
1212
- isCoroutine = true;
1211
+ if (!(0, types_1.isClassInstance)(subtype) || !types_1.ClassType.isBuiltIn(subtype, 'Coroutine')) {
1212
+ isCoroutine = false;
1213
1213
  }
1214
1214
  });
1215
1215
  if (isExprFunction) {
@@ -1681,6 +1681,15 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
1681
1681
  exemptBoundTypeVar = false;
1682
1682
  nameWalker.walk(node.returnTypeAnnotation);
1683
1683
  }
1684
+ if (node.functionAnnotationComment) {
1685
+ node.functionAnnotationComment.paramTypeAnnotations.forEach((expr) => {
1686
+ nameWalker.walk(expr);
1687
+ });
1688
+ if (node.functionAnnotationComment.returnTypeAnnotation) {
1689
+ exemptBoundTypeVar = false;
1690
+ nameWalker.walk(node.functionAnnotationComment.returnTypeAnnotation);
1691
+ }
1692
+ }
1684
1693
  localTypeVarUsage.forEach((usage) => {
1685
1694
  var _a;
1686
1695
  // Report error for local type variable that appears only once.
@@ -2713,7 +2722,8 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2713
2722
  const filterType = (varType) => {
2714
2723
  const filteredTypes = [];
2715
2724
  for (const filterType of classTypeList) {
2716
- const filterIsSuperclass = (0, typeGuards_1.isIsinstanceFilterSuperclass)(this._evaluator, varType, varType, filterType, filterType, isInstanceCheck);
2725
+ const filterIsSuperclass = (0, typeGuards_1.isIsinstanceFilterSuperclass)(this._evaluator, varType, varType, filterType, filterType, isInstanceCheck,
2726
+ /* isTypeIsCheck */ false);
2717
2727
  const filterIsSubclass = (0, typeGuards_1.isIsinstanceFilterSubclass)(this._evaluator, varType, filterType, isInstanceCheck);
2718
2728
  // Normally, a class should never be both a subclass and a
2719
2729
  // superclass. However, this can happen if one of the classes
@@ -3194,7 +3204,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
3194
3204
  }
3195
3205
  }
3196
3206
  _conditionallyReportPrivateUsage(node) {
3197
- var _a;
3207
+ var _a, _b;
3198
3208
  if (this._fileInfo.diagnosticRuleSet.reportPrivateUsage === 'none') {
3199
3209
  return;
3200
3210
  }
@@ -3214,7 +3224,11 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
3214
3224
  if (!isPrivateName && !isProtectedName) {
3215
3225
  return;
3216
3226
  }
3217
- const declarations = this._evaluator.getDeclarationsForNameNode(node);
3227
+ // Get the declarations for this name node, but filter out
3228
+ // any variable declarations that are bound using nonlocal
3229
+ // or global explicit bindings.
3230
+ const declarations = (_b = this._evaluator
3231
+ .getDeclarationsForNameNode(node)) === null || _b === void 0 ? void 0 : _b.filter((decl) => decl.type !== 1 /* DeclarationType.Variable */ || !decl.isExplicitBinding);
3218
3232
  let primaryDeclaration = declarations && declarations.length > 0 ? declarations[declarations.length - 1] : undefined;
3219
3233
  if (!primaryDeclaration || primaryDeclaration.node === node) {
3220
3234
  return;